HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/jsonschema/tests/__pycache__/_suite.cpython-310.pyc
o

>��]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)N�JSON_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__�parent�sibling�isdir�
ValueError)�root�r�9/usr/lib/python3/dist-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�
subprocess�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.6s�zSuite.benchmarkcCst||j�d|g�|��d�S)N�tests)rr&r)�Versionr r!r+�r*rrrrr-:s
�z
Suite.versionN)�__name__�
__module__�__qualname__�attr�ib�Factoryrr r+r.r-rrrrr's

rc@s\eZdZe��Ze��Ze��Zdd�Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�ZdS)r0c	Ks8|��D]}|D]}|�|jt|jfi|���qqdS�N)r/�
bench_func�fully_qualified_namer�validate_ignoring_errors)r*r,�kwargs�suite�testrrrr.Js���zVersion.benchmarkcs�fdd��j�d�D�S)Nc3�4�|]}�j|��dd�|d�D]}|VqqdS�N�����subjectr&��	_tests_in�basename�r�childr>�r*rr�	<genexpr>S������z Version.tests.<locals>.<genexpr>�*.json)�_path�globChildrenrIrrIrr/Rs

�z
Version.testscs(�j�ddg�}�fdd�|�d�D�S)N�optional�formatc3r?r@rDrGrIrrrJ^rKz'Version.format_tests.<locals>.<genexpr>rL)rMr!rN)r*r&rrIr�format_tests\s
�zVersion.format_testscCs|j||j�|d�d�S)N�.jsonrB)rErMrHr1rrr�tests_ofgs�zVersion.tests_ofcCs|j||j�d|dg�d�S)NrOrRrB)rErMr!r1rrr�optional_tests_ofms�zVersion.optional_tests_ofcs\��dd|j���}�fdd�|D�}t|tjf|�}zt�|_W|Sty-Y|Sw)Nr�Testc	s4i|]}|D]}|D]}|j|jdi����q
qqS)r)�method_name�to_unittest_method)rr=r/r>�r<rrrus���
�z0Version.to_unittest_testcase.<locals>.<dictcomp>)	�popr�title�type�unittest�TestCase�)_someone_save_us_the_module_of_the_callerr3�	Exception)r*�suitesr<r�methods�clsrrXr�to_unittest_testcasess
�
��zVersion.to_unittest_testcasec#s<�t�|���d��D]����fdd��dD�VqdS)Nrc	3s4�|]}td���d�d�jd�|��VqdS)�descriptionr)r-rC�case_descriptionrrNr)�_Testr+)rr>��eachr*rCrrrJ�s����
�z$Version._tests_in.<locals>.<genexpr>r/)rr'�
getContentr()r*rCr&rrgrrE�s�
��zVersion._tests_inN)r2r3r4r5r6rMr+rr.r/rQrSrTrcrErrrrr0Bs
r0F)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)rfF)rjcCsd�|j�S)Nz	<Test {}>)rPr:rIrrr�__repr__�sz_Test.__repr__cCsd�|jj|j|j|jg�S)Nz > )�joinr-rrCrerdrIrrrr:�s��z_Test.fully_qualified_namecCsHd}dt�|d|j�t�|d|j�t�|d|j�f}ts"|�d�}|S)Nz[\W\- ]+z
test_%s_%s_%s�_r)�re�subrCrerdr�encode)r*�
delimitersrrrrrV�s�
z_Test.method_namecCsdSr8r)r>rrr�<lambda>�sz_Test.<lambda>csH�jr��fdd�}n��fdd�}�j|_|��}t�|du|�|�S)Ncs�jdi���dS�Nr)�validate��this�r<r*rr�fn�sz$_Test.to_unittest_method.<locals>.fncsB|�tj���jdi���Wd�dS1swYdSrs)�assertRaisesr�ValidationErrorrtrurwrrrx�s"�)�validrVr2r\�skipIf)r*�skipr<rx�reasonrrwrrW�sz_Test.to_unittest_methodcKs:tjj|j|j|jd�}tjd|j|j||d�|��dS)N)r�store�id_of)�instancerrb�resolverr)r�RefResolver�from_schemarr+�ID_OFrt�data)r*�	Validatorr<r�rrrrt�s��
�z_Test.validatecCs*z	|j|d�WdStjyYdSw)N)r�)rtrrz)r*r�rrrr;�s
�z_Test.validate_ignoring_errorsN)r2r3r4r5r6r-rCrerdr�rr{r+rk�propertyr:rVrWrtr;rrrrrf�s"



rfcCst�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.
    �r2)r$�	_getframe�	f_globalsrrrrr^�s
r^)�__doc__�	functoolsrrrrnr"r$r\�twisted.python.filepathrr5�jsonschema.compatr�jsonschema.validatorsrrr�s�objectrr0rfr^rrrr�<module>s*

RL