L i dZddlmZddlmZddlmZddlmZddl m Z m Z ddl Z ddl Z ddlZddlZddlZddlmZmZdd lmZddlZe rdd lmZmZmZdd lmZddlZdd lmZddlZd Z ejBdZ"dZ#eGddZ$eGddZ%eGddZ& ddZ'edGddZ(dZ)y)z= Python representations of the JSON Schema Test Suite tests. ) annotations)suppress)partial)Path) TYPE_CHECKINGAnyN)fieldfrozen)Registry)IterableMappingSequence)Schema) _VALIDATORSzhttp://localhost:1234z[\W\- ]+ctjjd}| t|Sttj j j dz }|js td|S)NJSON_SCHEMA_TEST_SUITEjsonzCan'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.) osenvirongetr jsonschema__file__parentis_dir ValueError)roots ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jsonschema/tests/_suite.py _find_suiter"sh ::>>2 3D Dz  ## $ + + 2 2V ;D ;;=    Kc:eZdZUeeZded<ddZddZy) Suite)factoryr_rootctjD](\}}|j|j||*y)N)name)runner Validator)ritemsversion benchmark)selfr&r%r's rr*zSuite.benchmark:sB*002 OD) LLdL # - -# .  rc,t|}|j|j}tjj |}t jt|jdz |||}t||jdz |z |S)Nremotes)rr%uri)default_specificationtests)r%pathr-) rID_OF META_SCHEMA referencingrspecification_withr with_contents remotes_inr#Version)r+r%r'r. specificationregistrys rr)z Suite.versionAs% ??9#8#89#..AA#F :++ DJJ23 G"/, g%,  rNr&z pyperf.Runner)returnr8) __name__ __module__ __qualname__r rr#__annotations__r*r)rrr!r!4s ,E4,  rr!cXeZdZUded<ded<ded<dZddZdd Zdd Zd Zdd Z y )r8r_path%referencing.jsonschema.SchemaRegistry_remotesstrr%c R|jD]}|jdi|yNrA)casesr*)r+kwargscases rr*zVersion.benchmarkYs(JJL %D DNN $V $ %rcX|j|jjdS)N*.jsonpaths _cases_inrCglobr+s rrIz Version.cases]s ~~DJJOOH$=~>>rcX|j|jjdS)Nzoptional/format/*.jsonrNrPrSs r format_caseszVersion.format_cases`s!~~DJJOO4L$M~NNrcN|j|jdz |dz gS)Noptionalz.jsonrN)rQrC)r+r%s roptional_cases_ofzVersion.optional_cases_ofcs*~~TZZ*%<$u~%M$N~OOrcrjdd|jjjddz}fd|DDcic]}|j|}}t |t jf|}tt5t|_ ddd|Scc}w#1swY|SxYw)Nr%Test-c3rK|].}|D]'}|jD]}|jdi)0ywrH)r0to_unittest_method).0grouprKtestrJs r z/Version.to_unittest_testcase..jsW! JJ (''1&111s47) popr%titlereplacer=typeunittestTestCaser Exception)_someone_save_us_the_module_of_the_callerr>)r+groupsrJr%methodmethodsclss ` rto_unittest_testcasezVersion.to_unittest_testcasefszz&&499??+<+D+DS"+M"MN#  OOV #  4(++-w7 i  IFHCN I #  I s B' B,,B6c#K|D][}tj|jdD]1}tj |||j |j 3]yw)Nzutf-8)encoding)r)subjectr-)rloads read_text_Case from_dictstemrE)r+rOr1rKs rrQzVersion._cases_in{sb D 4>>7>#CD oo  II MM &  sA"A$N)r<Iterable[_Case])r%rFr<rx)rOzIterable[Path]r<rx) r=r>r?r@r*rIrUrXrorQrArrr8r8Qs4 K33 I%?OP*rr8cteZdZUded<ded<ded<ded<ded <d Zd ed <d Zded<edZddZy )rur8r)rFrr descriptionMapping[str, Any] | boolschemaz list[_Test]r0N str | NonecommentrAzSequence[dict[str, str]]r9c |j||jdDcgc]}td|d|d|d|d|d|!}}|dd|i|Scc}w)Nr0r)rrrzr|)r)rrcase_descriptionr|r-rA)updaterc_Test)rndatar-rJrar0s rrvz_Case.from_dicts F((7+    YY!%m!4H~         ''$''  s$Ac |jD]2}|j|jt|jfi|4yN)r0 bench_funcfully_qualified_namervalidate_ignoring_errors)r+r&rJras rr*z_Case.benchmarks?JJ D   ))55@@  rr;) r=r>r?r@r~r9 classmethodrvr*rArrrurusM L $$ GZ.0M+0 ( (rruc#dK|jdD]}tj|j}t |j |j dd}|dvr|jdk(s&d|vr#|jdr|j|std||fyw)NrM\/>draft3draft4treez$schemadraft) rglobrrsrtrF relative_torerw startswithMAGIC_REMOTE_URL)rr%r.eachr|relatives rr7r7s 8$7DNN,-t''-.66tSA,,II''''0 ++D1 !"!H:.66#7sB.B0F)reprceZdZUded<ded<ded<ded<ded<d ed <d ed <d ed<dZded<dZedZdfdZdZ dZ y)rr8r)rFrrrrzrrr{r|boolvalidrDrENr}r~c"d|jdS)Nz)rrSs r__repr__z_Test.__repr__s112!44rcdj|jj|j|j|j gS)Nz > )joinr)r%rrrrzrSs rrz_Test.fully_qualified_names>zz !! %%     rcyrrA)ras rz_Test.src $jrfd}nfd}djdtjdjtjdj tjdj g|_|}|#tjjdddk7r|Stjjdddk7rtj|Stj||S)Nc*jdiyrH)validatethisrJr+s rfnz$_Test.to_unittest_method..fns ''rc|jtj5jdidddy#1swYyxYwrH) assertRaisesrValidationErrorrrs rrz$_Test.to_unittest_method..fns=&&z'A'AB,!DMM+F+,,,s =A_raJSON_SCHEMA_DEBUG0JSON_SCHEMA_EXPECTED_FAILURES)rr _DELIMITERSsubrrrrzr=rrrrgexpectedFailureskip)r+rrJrreasons` ` rr^z_Test.to_unittest_methods :: ( ,hhT\\2T%:%:;T%5%56    d >RZZ^^,?ELI ZZ^^;S AS H++B/ /(8==(, ,rc  |j|j|d|j|jd|}tjj dddk7r t |j|jy)N)r|r:rr)instancerA) check_schemar|rErrr breakpointrr)r+r'rJ validators rrz_Test.validatesot{{+ ;;]]  ::>>-s 3s : LDII.rcttj5|j|dddy#1swYyxYw)N)r')rrrr)r+r's rrz_Test.validate_ignoring_errors s3 j00 1 / MMIM . / / /s6?) r=r>r?r@r~rpropertyrr^rrrArrrrsh L I $$ K33GZ5  '8-2 //rrcFtjdjdS)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. r=)sys _getframe f_globalsrArrrjrjs ==  % %j 11r)rrr%rFr.rFr<zIterable[tuple[str, Schema]])*__doc__ __future__r contextlibr functoolsrpathlibrtypingrrrrrerrgattrsr r r4r referencing.jsonschemacollections.abcr r rrpyperfjsonschema.validatorsrrrcompilerrr!r8rur7rrjrArrrs#%  ;;--*bjj% $   8111hD7 7 7 7" 7<UE/E/E/P 2r