HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/jsonschema/tests/__pycache__/_suite.cpython-39.pyc
a

�,�h� �@sTdZddlmZddlmZddlmZddlmZddl	m
Z
mZddlZddl
Z
ddlZddlZddlZddlmZmZdd	lmZddlZe
r�dd
lmZmZmZddlmZddlZddlmZddlZd
Z e�!d�Z"dd�Z#eGdd�d��Z$eGdd�d��Z%eGdd�d��Z&ddddd�dd�Z'edd�Gdd �d ��Z(d!d"�Z)dS)#z=
Python representations of the JSON Schema Test Suite tests.
�)�annotations)�suppress)�partial)�Path)�
TYPE_CHECKING�AnyN)�field�frozen)�Registry)�Iterable�Mapping�Sequence)�Schema)�_VALIDATORSzhttp://localhost:1234z[\W\- ]+cCsBtj�d�}|durt|�Sttj�jjd}|��s>td��|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__�parent�is_dir�
ValueError)�root�r�H/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/jsonschema/tests/_suite.py�_find_suite"s�rc@s<eZdZUeed�Zded<dd�dd�Zdd	�d
d�ZdS)
�Suite)�factoryr�_root�
pyperf.Runner��runnercCs,t��D]\}}|j|d�j||d�qdS)N)�name)r"�	Validator)r�items�version�	benchmark)�selfr"r#r$rrrr':s
�zSuite.benchmark�Version��returncCsXt|}|�|j�}tj�|�}t�jt|j	d||d�|d�}t
||j	d||d�S)N�remotes)rr#�uri)Zdefault_specification�tests)r#�pathr,)rZID_OFZMETA_SCHEMA�referencingrZspecification_withr
Z
with_contents�
remotes_inrr))r(r#r$r-�
specification�registryrrrr&As��z
Suite.versionN)	�__name__�
__module__�__qualname__rrr�__annotations__r'r&rrrrr4s
rc@sreZdZUded<ded<ded<dd�Zd	d
�dd�Zd	d
�d
d�Zdd	d�dd�Zdd�Zdd	d�dd�Z	dS)r)r�_path�%referencing.jsonschema.SchemaRegistry�_remotes�strr#cKs"|��D]}|jfi|��qdS�N)�casesr')r(�kwargs�caserrrr'YszVersion.benchmarkzIterable[_Case]r*cCs|j|j�d�d�S)N�*.json��paths��	_cases_inr8�glob�r(rrrr=]sz
Version.casescCs|j|j�d�d�S)Nzoptional/format/*.jsonrArCrFrrr�format_cases`szVersion.format_cases)r#r+cCs|j|jd|�d�gd�S)N�optionalz.jsonrA)rDr8)r(r#rrr�optional_cases_ofcszVersion.optional_cases_ofcs~��dd|j���dd��}dd��fdd�|D�D�}t|tjf|�}tt��t	�|_
Wd�n1sp0Y|S)	Nr#ZTest�-�cSsi|]}|j|�qSr)r4)�.0�methodrrr�
<dictcomp>hs�z0Version.to_unittest_testcase.<locals>.<dictcomp>c3s4|],}|D]"}|jD]}|jfi���Vqq
qdSr<)r.�to_unittest_method)rL�groupr?�test�r>rr�	<genexpr>js
�z/Version.to_unittest_testcase.<locals>.<genexpr>)�popr#�title�replace�type�unittestZTestCaser�	Exception�)_someone_save_us_the_module_of_the_callerr5)r(�groupsr>r#�methods�clsrrRr�to_unittest_testcasefs
��	
&zVersion.to_unittest_testcasezIterable[Path])rBr+ccs>|D]4}t�|jdd��D]}tj|||j|jd�VqqdS)Nzutf-8)�encoding)r&�subjectr,)r�loads�	read_text�_Case�	from_dict�stemr:)r(rBr/r?rrrrD{s�zVersion._cases_inN)
r4r5r6r7r'r=rGrIr^rDrrrrr)Qs
r)c@sheZdZUded<ded<ded<ded<ded	<d
Zded<d
Zded<edd��Zdd�dd�Zd
S)rcr)r&r;r`�description�Mapping[str, Any] | bool�schemazlist[_Test]r.N�
str | None�commentrzSequence[dict[str, str]]r2cs6��|���fdd���d�D�}|fd|i���S)Nc
s6g|].}tf�d�d�d�d�d�|���qS)r&r`rfrh)r&r`�case_descriptionrhr,)�_Test)rLrQ��datar,rr�
<listcomp>�s���z#_Case.from_dict.<locals>.<listcomp>r.)�updaterT)r]rnr,r>r.rrmrrd�s

�
z_Case.from_dictr r!cKs,|jD] }|�|jt|jfi|���qdSr<)r.Z
bench_func�fully_qualified_namer�validate_ignoring_errors)r(r"r>rQrrrr'�s

�z_Case.benchmark)	r4r5r6r7rjr2�classmethodrdr'rrrrrc�s

rcrr;zIterable[tuple[str, Schema]])rr#r-r+ccs||�d�D]l}t�|���}t|�|���dd�}|dvrD|jdks
d|vrb|�d�rb|�|�sbq
t	�d|��|fVq
dS)Nr@�\�/>Zdraft4Zdraft3�treez$schemaZdraft)
�rglobrrarbr;�relative_torVre�
startswith�MAGIC_REMOTE_URL)rr#r-Zeachrh�relativerrrr1�s
�����r1F)�reprc@s�eZdZUded<ded<ded<ded<ded<d	ed
<ded<d
ed<dZded<dd�Zedd��Zdd�fdd�Zdd�Z	dd�Z
dS)rlr)r&r;r`rkrfrrnrgrh�bool�validr9r:NrirjcCsd|j�d�S)Nz<Test �>)rqrFrrr�__repr__�sz_Test.__repr__cCsd�|jj|j|j|jg�S)Nz > )�joinr&r#r`rkrfrFrrrrq�s��z_Test.fully_qualified_namecCsdSr<r)rQrrr�<lambda>��z_Test.<lambda>c	s��jr��fdd�}n��fdd�}d�dt�d�j�t�d�j�t�d�j�g�|_|��}|dusxtj	�
dd�dkr||Stj	�
dd�dkr�t�|�St�
|�|�SdS)	Ncs�jfi���dSr<)�validate��this�r>r(rr�fn�sz$_Test.to_unittest_method.<locals>.fncs@|�tj�� �jfi���Wd�n1s20YdSr<)�assertRaisesr�ValidationErrorr�r�r�rrr��s�_rQ�JSON_SCHEMA_DEBUG�0ZJSON_SCHEMA_EXPECTED_FAILURES)r~r��_DELIMITERS�subr`rkrfr4rrrrXZexpectedFailure�skip)r(r�r>r��reasonrr�rrO�s ��
z_Test.to_unittest_methodcKsN|�|j�|f|j|jd�|��}tj�dd�dkr<t�|j|jd�dS)N)rhr3r�r�)�instance)	Zcheck_schemarhr:rrr�
breakpointr�rn)r(r$r>�	validatorrrrr�s��z_Test.validatecCs:ttj��|j|d�Wd�n1s,0YdS)N)r$)rrr�r�)r(r$rrrrrsz_Test.validate_ignoring_errors)r4r5r6r7rjr��propertyrqrOr�rrrrrrrl�s


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

    This is intended to allow us to dynamically 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.
    �r4)�sys�	_getframe�	f_globalsrrrrrZs
rZ)*�__doc__�
__future__r�
contextlibr�	functoolsr�pathlibr�typingrrrr�rer�rX�attrsrr	r0r
Zreferencing.jsonschema�collections.abcrrr
rZpyperfZjsonschema.validatorsrrrz�compiler�rrr)rcr1rlrZrrrr�<module>s@
4"H