name : _suite.cpython-39.pyc
a

 5q]H�@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlZddlm
Z
ddlmZddlZdd�Zejd	d
�Gdd�de��Zejd	d
�Gd
d�de��Zejd	dd�Gdd�de��Zdd�ZdS)z=
Python representations of the JSON Schema Test Suite tests.
�)�partialN)�FilePath)�PY3)�
validatorscCsDtj�d�}|durt|�Sttj����d�}|��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�;/usr/lib/python3.9/site-packages/jsonschema/tests/_suite.py�_find_suites�rT)�hashc@s6eZdZeje�e�d�Zdd�Zdd�Z	dd�Z
dS)	�Suite)�defaultcCsB|j�ddg�}t�tj|jdg�}dd�t�|�	d���
�D�S)N�bin�jsonschema_suite�remotescSsi|]\}}d||�qS)zhttp://localhost:1234/r)�.0�name�schemarrr�
<dictcomp>1s�z"Suite._remotes.<locals>.<dictcomp>�utf-8)�_root�
descendant�
subprocessZcheck_output�sys�
executable�pathr�loads�decode�items)�selfrrrrr�_remotes,s��zSuite._remotescCs"tD]}|j|d�j|d�qdS)N)r)�runner)r�version�	benchmark)r'r)rrrrr+6szSuite.benchmarkcCst||j�d|g�|��d�S)N�tests)rr#r)�Versionrrr(�r'rrrrr*:s
�z
Suite.versionN)�__name__�
__module__�__qualname__�attr�ibZFactoryrrr(r+r*rrrrr's
rc@s\eZdZe��Ze��Ze��Zdd�Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�ZdS)r-c	Ks8|��D]*}|D] }|�|jt|jfi|���qqdS�N)r,Z
bench_func�fully_qualified_namer�validate_ignoring_errors)r'r)�kwargs�suite�testrrrr+Js�zVersion.benchmarkcs�fdd��j�d�D�S)Nc3s2|]*}�j|��dd�|d�D]
}|Vq qdS�N�����subjectr#��	_tests_in�basename�r�childr9�r'rr�	<genexpr>Ss�
�z Version.tests.<locals>.<genexpr>�*.json)�_path�globChildrenrCrrCrr,Rs

�z
Version.testscs(�j�ddg�}�fdd�|�d�D�S)N�optional�formatc3s2|]*}�j|��dd�|d�D]
}|Vq qdSr:r>rArCrrrD^s�
�z'Version.format_tests.<locals>.<genexpr>rE)rFrrG)r'r#rrCr�format_tests\s
�zVersion.format_testscCs|j||j�|d�d�S)N�.jsonr<)r?rFrBr.rrr�tests_ofgs�zVersion.tests_ofcCs|j||j�d|dg�d�S)NrHrKr<)r?rFrr.rrr�optional_tests_ofms�zVersion.optional_tests_ofcs\��dd|j���}�fdd�|D�}t|tjf|�}zt�|_WntyVYn0|S)NrZTestc	s4i|],}|D]"}|D]}|j|jfi����qqqSr)�method_name�to_unittest_method)rr8r,r9�r7rrrus�z0Version.to_unittest_testcase.<locals>.<dictcomp>)	�popr�title�type�unittestZTestCase�)_someone_save_us_the_module_of_the_callerr0�	Exception)r'Zsuitesr7r�methods�clsrrPr�to_unittest_testcasess
�zVersion.to_unittest_testcasec#s:t�|���d��D] ����fdd��dD�VqdS)Nrc	3s2|]*}tf���d�d�jd�|��VqdS)�descriptionr)r*r=�case_descriptionrrN)�_Testr()rr9�Zeachr'r=rrrD�s���z$Version._tests_in.<locals>.<genexpr>r,)rr$Z
getContentr%)r'r=r#rr]rr?�s�zVersion._tests_inN)r/r0r1r2r3rFr(rr+r,rJrLrMrYr?rrrrr-Bs
r-F)r�reprc@s�eZdZe��Ze��Ze��Ze��Ze��Z	ejdd�Z
e��Ze��Zdd�Z
edd��Zedd��Zd	d
�fdd�Zd
d�Zdd�ZdS)r\F)r^cCsd�|j�S)Nz	<Test {}>)rIr5rCrrr�__repr__�sz_Test.__repr__cCsd�|jj|j|j|jg�S)Nz > )�joinr*rr=r[rZrCrrrr5�s��z_Test.fully_qualified_namecCsHd}dt�|d|j�t�|d|j�t�|d|j�f}tsD|�d�}|S)Nz[\W\- ]+z
test_%s_%s_%s�_r)�re�subr=r[rZr�encode)r'Z
delimitersrrrrrN�s�
z_Test.method_namecCsdSr4r)r9rrr�<lambda>��z_Test.<lambda>csH�jr��fdd�}n��fdd�}�j|_|��}t�|du|�|�S)Ncs�jfi���dSr4)�validate��this�r7r'rr�fn�sz$_Test.to_unittest_method.<locals>.fncs@|�tj�� �jfi���Wd�n1s20YdSr4)ZassertRaisesr
�ValidationErrorrgrhrjrrrk�s)�validrNr/rTZskipIf)r'�skipr7rk�reasonrrjrrO�sz_Test.to_unittest_methodcKs:tjj|j|j|jd�}tjf|j|j||d�|��dS)N)r�storeZid_of)�instancerrX�resolver)r
ZRefResolverZfrom_schemarr(ZID_OFrg�data)r'�	Validatorr7rrrrrrg�s���z_Test.validatecCs*z|j|d�Wntjy$Yn0dS)N)rt)rgr
rl)r'rtrrrr6�sz_Test.validate_ignoring_errorsN)r/r0r1r2r3r*r=r[rZrsrrmr(r_�propertyr5rNrOrgr6rrrrr\�s 



r\cCst�d�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_globalsrrrrrU�s
rU)�__doc__�	functoolsrrrrbr r!rTZtwisted.python.filepathrr2Zjsonschema.compatrZjsonschema.validatorsrr
r�s�objectrr-r\rUrrrr�<module>s(

RL

© 2025 Cubjrnet7