L i=ddlmZddlmZddlmZmZddlZddl Z ddl Z ddl Z ddl Z ddlZddlmZmZmZmZGddeZy))contextmanager)BytesIO)TestCasemockN) FormatChecker exceptions protocols validatorsceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZy)TestDeprecationscd}|jt|5}ddlm}ddd|j t j jd|j jty#1swYYxYw)zY As of v4.0.0, __version__ is deprecated in favor of importlib.metadata. z.Accessing jsonschema.__version__ is deprecatedr) __version__N jsonschema) assertWarnsRegexDeprecationWarningrr assertEqual importlibmetadataversionfilename__file__)selfmessagewrs h/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jsonschema/tests/test_deprecations.py test_versionzTestDeprecations.test_versionsl C  " "#5w ? /1 . / i&8&8&@&@&NO X.  / /s A88Bcd}|jt|5}ddlm}ddd|j t j|j j ty#1swYJxYw)z As of v4.0.0, importing ErrorTree from jsonschema.validators is deprecated in favor of doing so from jsonschema.exceptions. z2Importing ErrorTree from jsonschema.validators is r ErrorTreeN)rrjsonschema.validatorsrrrrrrrrrs rtest_validators_ErrorTreez*TestDeprecations.test_validators_ErrorTreesa G  " "#5w ? 81 7 8 J$8$89 X.  8 8 A))A2cd}|jt|5}ddlm}ddd|j t j|j j ty#1swYJxYw)z As of v4.18.0, importing ErrorTree from the package root is deprecated in favor of doing so from jsonschema.exceptions. z9Importing ErrorTree directly from the jsonschema package rrN)rrrrrrrrr!s rtest_import_ErrorTreez&TestDeprecations.test_import_ErrorTree)sa N  " "#5w ? -1 , - J$8$89 X.  - -r#cXtjddg}tj}tj|g}d}|jt|5}||d<ddd|j |d||j j ty#1swY?xYw)zM As of v4.20.0, setting items on an ErrorTree is deprecated. z some errorfoo)path)errorszErrorTree.__setitem__ is N)rValidationErrorrrrrrr)retreesubtreerrs rtest_ErrorTree_setitemz'TestDeprecations.test_ErrorTree_setitem6s  & &|5' B##%&&qc2-  " "#5w ? "1!DK " eg. X.  " "s B  B)cd}|jt|5}ddlm}ddd|j t j|j j ty#1swYJxYw)z As of v4.18.0, importing FormatError from the package root is deprecated in favor of doing so from jsonschema.exceptions. z;Importing FormatError directly from the jsonschema package r) FormatErrorN)rrrr0rrrr)rrrr0s rtest_import_FormatErrorz(TestDeprecations.test_import_FormatErrorFsa P  " "#5w ? /1 . / j&<&<= X.  / /r#cd}|jt|5}ddlm}ddd|j t j|j j ty#1swYJxYw)z As of v4.19.0, importing Validator from the package root is deprecated in favor of doing so from jsonschema.protocols. z9Importing Validator directly from the jsonschema package r) ValidatorN)rrrr3rr rr)rrrr3s rtest_import_Validatorz&TestDeprecations.test_import_ValidatorSsa N  " "#5w ? -1 , - I$7$78 X.  - -r#cd}|jt|5}tj}ddd|jtj|jj t y#1swYJxYw)za As of v4.0.0, accessing jsonschema.validators.validators is deprecated. z8Accessing jsonschema.validators.validators is deprecatedN)rrr r _VALIDATORSrrrrrvalues rtest_validators_validatorsz+TestDeprecations.test_validators_validators`si M  " "#5w ? *1))E *  6 67 X.  * * A33A<cd}|jt|5}tj}ddd|j tj |j j ty#1swYJxYw)zc As of v4.0.0, accessing jsonschema.validators.meta_schemas is deprecated. z:Accessing jsonschema.validators.meta_schemas is deprecatedN)rrr meta_schemasr _META_SCHEMASrrr7s rtest_validators_meta_schemasz-TestDeprecations.test_validators_meta_schemasmsi O  " "#5w ? ,1++E ,  8 89 X.  , ,r:c*tjji}d}|jt|5}|j d5 dddddd|j jty#1swY2xYw#1swY6xYw)zC As of v4.0.0, RefResolver.in_scope is deprecated. z.jsonschema.RefResolver.in_scope is deprecated r'N) r _RefResolver from_schemarrin_scoperrr)rresolverrrs rtest_RefResolver_in_scopez*TestDeprecations.test_RefResolver_in_scopezs **66r:B  " "#5w ? 1""5)    X.    s#B  A= B =B B  Bctji}d}|jt|5}|j dddi}ddd|j |j jty#1swY;xYw)zz As of v4.0.0, calling is_valid with two arguments (to provide a different schema) is deprecated. z5Passing a schema to Validator.is_valid is deprecated r'typenumberN) r Draft7Validatorrris_valid assertFalserrr)r validatorrrresults r%test_Validator_is_valid_two_argumentsz6TestDeprecations.test_Validator_is_valid_two_argumentss ..r2 I  " "#5w ? C1''/ABF C   X.  C Cs A==Bc,tji}d}|jt|5}|j dddi\}ddd|j j d|j jty#1swYFxYw)z} As of v4.0.0, calling iter_errors with two arguments (to provide a different schema) is deprecated. z8Passing a schema to Validator.iter_errors is deprecated r'rFrGN) r rHrr iter_errorsrrKrr)rrKrrerrors r(test_Validator_iter_errors_two_argumentsz9TestDeprecations.test_Validator_iter_errors_two_argumentss ..r2 L  " "#5w ? F1**5682DEFE F &1 X.  F Fs B  Bctji}d}|jt|5}|j |j tj ddd|jjty#1swY*xYw)zL As of v4.18.0, accessing Validator.resolver is deprecated. z&Accessing Draft7Validator.resolver is N) r rHrrassertIsInstancerCr@rrr)rrKrrs rtest_Validator_resolverz(TestDeprecations.test_Validator_resolversw ..r2 :  " "#5w ? O1  ! !)"4"4j6M6M N O X. O Os +BB cLd}|jt|5}ddlm}ddd|j j t |jt|5}ddlm}ddd|j |j t y#1swYoxYw#1swY6xYw)zA As of v4.18.0, RefResolver is fully deprecated. z$jsonschema.RefResolver is deprecatedr) RefResolverN)rrrrVrrrr )rrrrVs rtest_RefResolverz!TestDeprecations.test_RefResolvers 9  " "#5w ? /1 . / X.  " "#5w ? :1 9 : X.  / / : :sBBBB#cd}|jt|5}ddlm}ddd|j t j |j jt|jt|5}ddl m}ddd|j |t j |j |jty#1swYxYw#1swYVxYw)z As of v4.18.0, RefResolutionError is deprecated in favor of directly catching errors from the referencing library. z6jsonschema.exceptions.RefResolutionError is deprecatedrRefResolutionErrorN) rrrrZrr_RefResolutionErrorrrjsonschema.exceptions)rrrrZs rtest_RefResolutionErrorz(TestDeprecations.test_RefResolutionErrors K  " "#5w ? 61 5 6 +Z-K-KL X.  " "#5w ? A1 @ A +Z-K-KL X. 6 6  A AsC>CCC#cvtjddi}|jtjj 5}|j ddddtjj d}|jjt|jf|dfy#1swY]xYw)a This behavior is the intended behavior (i.e. it's not deprecated), but given we do "tricksy" things in the iterim to wrap exceptions in a multiple inheritance subclass, we need to be extra sure it works and stays working. $ref urn:nothing N)refUnresolvable: urn:nothing) r Draft202012Validator assertRaises referencingr Unresolvablevalidater exceptionstr)rrKr+expecteds r#test_catching_Unresolvable_directlyz4TestDeprecations.test_catching_Unresolvable_directlys33V]4KL   {55BB C #q   r " #))66=6I  [[#akk* + 2 3  # #s B//B8c|jt5ddlm}dddt j ddi}|j tjj5}|jdddd|j 5}|jdddd|jjt|jfjdfy#1swYxYw#1swY~xYw#1swY_xYw)z Until RefResolutionError is removed, it is still possible to catch exceptions from reference resolution using it, even though they may have been raised by referencing. rrYNr_r`rarc) assertWarnsrrrZr rdrerfrrgrhrrirjrrZrKur+s r1test_catching_Unresolvable_via_RefResolutionErrorzBTestDeprecations.test_catching_Unresolvable_via_RefResolutionErrors   0 1 6 5 633V]4KL   {55BB C #q   r " #  1 2 #a   r " #  [[#akk* + [[5 6  6 6  # # # #s#C(%C4D(C14C=D c:|jt5ddlm}dddt j ddi}|j tjj5}|jdddd|j 5}|jdddd|jjjh|j|j|jhy#1swYxYw#1swYxYw#1swYpxYw)zS Ensure the wrapped referencing errors are hashable when possible. rrYNr_r`ra) rnrrrZr rdrerfrrgrhassertInriros r(test_WrappedReferencingError_hashabilityz9TestDeprecations.test_WrappedReferencingError_hashabilitys  0 1 6 5 633V]4KL   {55BB C #q   r " #  1 2 #a   r " # akkAKK=1 akkAKK=1 6 6  # # # #s#C9%DD9DDDcdd}|jt|5}Gddtj}ddd|j j t |jt|5}Gddtji}dddy#1swYhxYw#1swYyxYw)ac As of v4.12.0, subclassing a validator class produces an explicit deprecation warning. This was never intended to be public API (and some comments over the years in issues said so, but obviously that's not a great way to make sure it's followed). A future version will explicitly raise an error. z!Subclassing validator classes is c eZdZy)=TestDeprecations.test_Validator_subclassing..SubclassN__name__ __module__ __qualname__rSubclassrwr}r~Nc eZdZy)DTestDeprecations.test_Validator_subclassing..AnotherSubclassNrxr|r}rAnotherSubclassrrr}r) meta_schema)rrr rdrrrcreate)rrrr~rs rtest_Validator_subclassingz+TestDeprecations.test_Validator_subclassing s6  " "#5w ? 1 :::   X.  " "#5w ? 1 *"3"3"C         sB1 B&B#&B/c|jtjjddd}|j t |5}tj dddd|jjty#1swY*xYw)zd As of v4.14.0, FormatChecker.cls_checks is deprecated without replacement. boomNzFormatChecker.cls_checks ) addCleanuprcheckerspoprr cls_checksrrr)rrrs rtest_FormatChecker_cls_checksz.TestDeprecations.test_FormatChecker_cls_checks!sq  ..22FDA-  " "#5w ? -1  $ $V , - X. - -s BB cJd}|jt|5}ddlm}ddd|j t j j|jjtd}|jt|5}ddlm }ddd|j t jj|j|jtd}|jt|5}ddlm }ddd|j t jj|j|jtd }|jt|5}dd lm}ddd|j t j j|j|jtd }|jt|5}dd lm}ddd|j t j$j|j|jtd }|jt|5}ddlm}ddd|j t j(j|j|jt|j+t,5ddlm} dddy#1swYxYw#1swYJxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYyxYw)z As of v4.16.0, accessing jsonschema.draftn_format_checker is deprecated in favor of Validator.FORMAT_CHECKER. z3Accessing jsonschema.draft202012_format_checker is r)draft202012_format_checkerNz3Accessing jsonschema.draft201909_format_checker is )draft201909_format_checkerz.Accessing jsonschema.draft7_format_checker is )draft7_format_checkerz.Accessing jsonschema.draft6_format_checker is )draft6_format_checkerz.Accessing jsonschema.draft4_format_checker is )draft4_format_checkerz.Accessing jsonschema.draft3_format_checker is )draft3_format_checker)draft1234_format_checker)rrrrassertIsr rdFORMAT_CHECKERrrrrDraft201909ValidatorrrHrDraft6ValidatorrDraft4ValidatorrDraft3Validatorre ImportErrorr) rrrrrrrrrrs rtest_draftN_format_checkerz+TestDeprecations.test_draftN_format_checker/s H  " "#5w ? >1 = > &  + + : :  X.G  " "#5w ? >1 = > &  + + : :  X.B  " "#5w ? 91 8 9 !  & & 5 5  X.B  " "#5w ? 91 8 9 !  & & 5 5  X.B  " "#5w ? 91 8 9 !  & & 5 5  X.B  " "#5w ? 91 8 9 !  & & 5 5  X.   { + < ; <  > > > 9 9 9 9 9 9 9 9 < .fake_urlopens  ! !'6>>+A+A B   W--| < '335 OVU   V\\^\ :   G $**V,33F;< Cr_z+Automatically retrieving remote references urlopen)new%)FT)rmodulesr __setitem__rr rdrpatchobjectrrrrrrI)rrbrrKrrrs` @rtest_automatic_remote_retrievalz0TestDeprecations.test_automatic_remote_retrievals&EFI#678  $ OO ''S[[5L #' J  =  =33VSMB ? !!&..)!N  D))*rDrMrQrTrWr]rlrqrtrrrrrrr|r}rr r sx / / // / / / / / / / / //& $ ,2$. /Crs4%#  GGaxar}