Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/jsonschema/tests/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/jsonschema/tests/__pycache__/_suite.cpython-35.pyc



�$�]��@s0dZddlZddlZddlZddlZddlZddlZddlmZddl	Z	ddl
mZddlm
Z
ddlZdd�Ze	jdd	�Gd
d�de��Ze	jdd	�Gdd
�d
e��Ze	jdd	dd�Gdd�de��Zdd�ZdS)z>
Python representations of the JSON Schema Test Suite tests.

�N)�FilePath)�PY3)�
validatorscCsbtjjd�}|dk	r(t|�Sttj�j�jd�}|j�s^t	d��|S)NZJSON_SCHEMA_TEST_SUITE�jsonz�Can't find the JSON-Schema-Test-Suite directory. Set the 'JSON_SCHEMA_TEST_SUITE' environment variable or run the tests from alongside a checkout of the suite.)
�os�environ�getr�
jsonschema�__file__�parentZsibling�isdir�
ValueError)�root�r�H/opt/alt/python35/lib/python3.5/site-packages/jsonschema/tests/_suite.py�_find_suites
	r�hashTc@sOeZdZejdeje��Zdd�Zdd�Z	dd�Z
dS)	�Suite�defaultcCs_|jjddg�}tjtj|jdg�}dd�tj|j	d��j
�D�S)N�bin�jsonschema_suite�remotescSs#i|]\}}|d|�qS)zhttp://localhost:1234/r)�.0�name�schemarrr�
<dictcomp>1s	z"Suite._remotes.<locals>.<dictcomp>zutf-8)�_root�
descendant�
subprocess�check_output�sys�
executable�pathr�loads�decode�items)�selfrrrrr�_remotes,s
	zSuite._remotescCs1x*tD]"}|jd|�jd|�qWdS)Nr�runner)r�version�	benchmark)r&r(rrrrr*6s
zSuite.benchmarkcCs1td|d|jjd|g�d|j��S)Nrr"�testsr)�Versionrrr')r&rrrrr):sz
Suite.versionN)�__name__�
__module__�__qualname__�attr�ibZFactoryrrr'r*r)rrrrr's
rc@s�eZdZej�Zej�Zej�Zdd�Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�ZdS)r,cCsHxA|j�D]3}x*|D]"}|jd|jd|j�qWq
WdS)Nr�func)r+Z
bench_func�fully_qualified_name�validate_ignoring_errors)r&r(�suite�testrrrr*Js

		zVersion.benchmarkcs#�fdd��jjd�D�S)Nc3sD|]:}�jd|j�dd�d|�D]}|Vq/qdS)�subjectN�r"���)�	_tests_in�basename)r�childr6)r&rr�	<genexpr>Ts	z Version.tests.<locals>.<genexpr>z*.json)�_path�globChildren)r&r)r&rr+Rsz
Version.testscs8�jjddg�}�fdd�|jd�D�S)N�optional�formatc3sD|]:}�jd|j�dd�d|�D]}|Vq/qdS)r7Nr8r"r9)r:r;)rr<r6)r&rrr=_s	z'Version.format_tests.<locals>.<genexpr>z*.json)r>rr?)r&r"r)r&r�format_tests\szVersion.format_testscCs&|jd|d|jj|d��S)Nr7r"z.json)r:r>r<)r&rrrr�tests_ofgs	zVersion.tests_ofcCs,|jd|d|jjd|dg��S)Nr7r"r@z.json)r:r>r)r&rrrr�optional_tests_ofms	zVersion.optional_tests_ofcsy�jdd|jj��}�fdd�|D�}t|tjf|�}yt�|_Wntk
rtYnX|S)NrZTestcs?i|]5}|D](}|D]}|j��|j�qqqSr)�to_unittest_method�method_name)rr5r+r6)�kwargsrrrus	
z0Version.to_unittest_testcase.<locals>.<dictcomp>)	�popr�title�type�unittestZTestCase�)_someone_save_us_the_module_of_the_callerr.�	Exception)r&ZsuitesrGr�methods�clsr)rGr�to_unittest_testcasess

zVersion.to_unittest_testcasec#sOxHtj|j�jd��D](����fdd��dD�VqWdS)Nzutf-8c
3sD|]:}td�d�d�dd�dd�j|�VqdS)r)r7�case_description�descriptionrrN)�_Testr')rr6)�eachr&r7rrr=�sz$Version._tests_in.<locals>.<genexpr>r+)rr#Z
getContentr$)r&r7r"r)rTr&r7rr:�s%zVersion._tests_inN)r-r.r/r0r1r>r'rr*r+rBrCrDrPr:rrrrr,Bs
r,�reprFc@s�eZdZej�Zej�Zej�Zej�Zej�Z	ejdd�Z
ej�Zej�Zdd�Z
edd��Zedd��Zd	d
�dd�Zd
dd�Zdd�Zd
S)rSrUFcCsdj|j�S)Nz	<Test {}>)rAr3)r&rrr�__repr__�sz_Test.__repr__cCs(dj|jj|j|j|jg�S)Nz > )�joinr)rr7rQrR)r&rrrr3�s
	z_Test.fully_qualified_namecCshd}dtj|d|j�tj|d|j�tj|d|j�f}tsd|jd�}|S)Nz[\W\- ]+z
test_%s_%s_%s�_zutf-8)�re�subr7rQrRr�encode)r&�
delimitersrrrrrF�sz_Test.method_namecCsdS)Nr)r6rrr�<lambda>�sz_Test.<lambda>csj�jr!��fdd�}n��fdd�}�j|_|��}tj|dk	|�|�S)Ncs�j��dS)N)�validate)�this)rGr&rr�fn�sz$_Test.to_unittest_method.<locals>.fnc	s+|jtj���j��WdQRXdS)N)ZassertRaisesr	�ValidationErrorr^)r_)rGr&rrr`�s)�validrFr-rKZskipIf)r&�skiprGr`�reasonr)rGr&rrE�s	z_Test.to_unittest_methodNc
KsPtjjd|jd|j�}tjd|jd|jd|d||�dS)Nr�store�instancerO�resolver)r	ZRefResolverZfrom_schemarr'r^�data)r&Z	ValidatorrGrgrrrr^�s			z_Test.validatecKs-y|j|�Wntjk
r(YnXdS)N)r^r	ra)r&rGrrrr4�sz_Test.validate_ignoring_errors)r-r.r/r0r1r)r7rQrRrhrrbr'rV�propertyr3rFrEr^r4rrrrrS�s

rScCstjd�jdS)a�
    The FQON of the module 2nd stack frames up from here.

    This is intended to allow us to dynamicallly return test case classes that
    are indistinguishable from being defined in the module that wants them.

    Otherwise, trial will mis-print the FQON, and copy pasting it won't re-run
    the class that really is running.

    Save us all, this is all so so so so so terrible.
    �r-)r �	_getframe�	f_globalsrrrrrL�s
rL)�__doc__rrrYrr rKZtwisted.python.filepathrr0Zjsonschema.compatrZjsonschema.validatorsrr	r�s�objectrr,rSrLrrrr�<module>s&R"J