
    {gJ;                         S SK Jr  S SKJr  S SKJrJr  S SKrS SK	r	S SK
r
S SKrS SKrS SKrS SKJrJrJrJr   " S S\5      rg)    )contextmanager)BytesIO)TestCasemockN)FormatChecker
exceptions	protocols
validatorsc                       \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)TestDeprecations   c                    SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  R                  S5      5        U R	                  WR                  [        5        g! , (       d  f       N^= f)zI
As of v4.0.0, __version__ is deprecated in favor of importlib.metadata.
z.Accessing jsonschema.__version__ is deprecatedr   )__version__N
jsonschema)
assertWarnsRegexDeprecationWarningr   r   assertEqual	importlibmetadataversionfilename__file__)selfmessagewr   s       D/usr/lib/python3/dist-packages/jsonschema/tests/test_deprecations.pytest_versionTestDeprecations.test_version   sg    
 C""#5w?1. @ 	i&8&8&@&@&NOX.	 @?s   A88
Bc                     SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  5        U R	                  WR                  [        5        g! , (       d  f       NO= f)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)r   r   jsonschema.validatorsr!   r   r   r   r   r   r   r   r!   s       r   test_validators_ErrorTree*TestDeprecations.test_validators_ErrorTree   s\     G""#5w?17 @ 	J$8$89X.	 @?   A))
A7c                     SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  5        U R	                  WR                  [        5        g! , (       d  f       NO= f)zy
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 r   r    N)r   r   r   r!   r   r   r   r   r#   s       r   test_import_ErrorTree&TestDeprecations.test_import_ErrorTree)   s\     N""#5w?1, @ 	J$8$89X.	 @?r&   c                     SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  5        U R	                  WR                  [        5        g! , (       d  f       NO= f)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)r   r   r   r+   r   r   r   r   )r   r   r   r+   s       r   test_import_FormatError(TestDeprecations.test_import_FormatError6   s\     P""#5w?1. @ 	j&<&<=X.	 @?r&   c                     SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  5        U R	                  WR                  [        5        g! , (       d  f       NO= f)zx
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)r   r   r   r/   r   r	   r   r   )r   r   r   r/   s       r   test_import_Validator&TestDeprecations.test_import_ValidatorC   s\     N""#5w?1, @ 	I$7$78X.	 @?r&   c                    SnU R                  [        U5       n[        R                  nSSS5        U R                  W[        R                  5        U R                  WR
                  [        5        g! , (       d  f       NO= f)zI
As of v4.0.0, accessing jsonschema.validators.validators is
deprecated.
z8Accessing jsonschema.validators.validators is deprecatedN)r   r   r
   r   _VALIDATORSr   r   r   r   r   values       r   test_validators_validators+TestDeprecations.test_validators_validatorsP   sd     M""#5w?1))E @ 	
 6 67X.	 @?   A33
Bc                    SnU R                  [        U5       n[        R                  nSSS5        U R	                  W[        R
                  5        U R	                  WR                  [        5        g! , (       d  f       NO= f)zK
As of v4.0.0, accessing jsonschema.validators.meta_schemas is
deprecated.
z:Accessing jsonschema.validators.meta_schemas is deprecatedN)r   r   r
   meta_schemasr   _META_SCHEMASr   r   r4   s       r   test_validators_meta_schemas-TestDeprecations.test_validators_meta_schemas]   sd     O""#5w?1++E @ 	
 8 89X.	 @?r8   c                 >   [         R                  R                  0 5      nSnU R                  [        U5       nUR                  S5          SSS5        SSS5        U R                  WR                  [        5        g! , (       d  f       N7= f! , (       d  f       N@= f)z3
As of v4.0.0, RefResolver.in_scope is deprecated.
z.jsonschema.RefResolver.in_scope is deprecated fooN)	r
   _RefResolverfrom_schemar   r   in_scoper   r   r   )r   resolverr   r   s       r   test_RefResolver_in_scope*TestDeprecations.test_RefResolver_in_scopej   sw    
 **66r:B""#5w?1""5) * @ 	X. *) @?s#   B
A=B=
B	B
Bc                    [         R                  " 0 5      nSnU R                  [        U5       nUR	                  SSS05      nSSS5        U R                  W5        U R                  WR                  [        5        g! , (       d  f       N@= f)zb
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?   typenumberN)	r
   Draft7Validatorr   r   is_validassertFalser   r   r   )r   	validatorr   r   results        r   %test_Validator_is_valid_two_arguments6TestDeprecations.test_Validator_is_valid_two_argumentsw   sw     ..r2	I""#5w?1''/ABF @ 	 X.	 @?s   A>>
Bc                 8   [         R                  " 0 5      nSnU R                  [        U5       nUR	                  SSS05      u  nSSS5        U R                  WR                  S5        U R                  WR                  [        5        g! , (       d  f       NK= f)ze
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?   rG   rH   N)	r
   rI   r   r   iter_errorsr   rL   r   r   )r   rL   r   r   errors        r   (test_Validator_iter_errors_two_arguments9TestDeprecations.test_Validator_iter_errors_two_arguments   s     ..r2	L""#5w?1**5682DEFE @ 	&1X.	 @?s   B
Bc                 (   [         R                  " 0 5      nSnU R                  [        U5       nU R	                  UR
                  [         R                  5        SSS5        U R                  WR                  [        5        g! , (       d  f       N/= f)z<
As of v4.18.0, accessing Validator.resolver is deprecated.
z&Accessing Draft7Validator.resolver is N)
r
   rI   r   r   assertIsInstancerC   r@   r   r   r   )r   rL   r   r   s       r   test_Validator_resolver(TestDeprecations.test_Validator_resolver   sn    
 ..r2	:""#5w?1!!)"4"4j6M6MN @ 	X. @?s   +B
Bc                 `   SnU R                  [        U5       nSSKJn  SSS5        U R	                  WR
                  [        5        U R                  [        U5       nSSKJn  SSS5        U R	                  UR
                  [        5        g! , (       d  f       Nt= f! , (       d  f       N@= f)z1
As of v4.18.0, RefResolver is fully deprecated.
z$jsonschema.RefResolver is deprecatedr   )RefResolverN)r   r   r   rZ   r   r   r   r"   )r   r   r   rZ   s       r   test_RefResolver!TestDeprecations.test_RefResolver   s}    
 9""#5w?1. @X.""#5w?19 @X. @? @?s   BB
B
B-c                    SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  5        U R	                  WR                  [        5        U R                  [        U5       nSSK	Jn  SSS5        U R	                  U[
        R                  5        U R	                  UR                  [        5        g! , (       d  f       N= f! , (       d  f       N`= f)zt
As of v4.18.0, RefResolutionError is deprecated in favor of directly
catching errors from the referencing library.
z6jsonschema.exceptions.RefResolutionError is deprecatedr   RefResolutionErrorN)
r   r   r   r_   r   r   _RefResolutionErrorr   r   jsonschema.exceptions)r   r   r   r_   s       r   test_RefResolutionError(TestDeprecations.test_RefResolutionError   s     K""#5w?15 @ 	+Z-K-KLX.""#5w?1@ @ 	+Z-K-KLX. @? @?s   C>C
C
C-c                 |   [         R                  " SS05      nU R                  [        R                  R
                  5       nUR                  S5        SSS5        [        R                  R                  SS9nU R                  WR                  [        UR                  5      4US45        g! , (       d  f       N_= f)z
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)refUnresolvable: urn:nothing)
r
   Draft202012ValidatorassertRaisesreferencingr   Unresolvablevalidater   	exceptionstr)r   rL   eexpecteds       r   #test_catching_Unresolvable_directly4TestDeprecations.test_catching_Unresolvable_directly   s     33V]4KL	{55BBCqr" D ))66=6I[[#akk*+23	
	 DCs   B--
B;c                 8   U R                  [        5         SSKJn  SSS5        [        R
                  " SS05      nU R                  [        R                  R                  5       nUR                  S5        SSS5        U R                  W5       nUR                  S5        SSS5        U R                  WR                  [        UR                  5      4WR                  S45        g! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Nn= f)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.
r   r^   Nre   rf   rg   ri   )assertWarnsr   r   r_   r
   rj   rk   rl   r   rm   rn   r   ro   rp   r   r_   rL   urq   s        r   1test_catching_Unresolvable_via_RefResolutionErrorBTestDeprecations.test_catching_Unresolvable_via_RefResolutionError   s     015 2 33V]4KL	{55BBCqr" D 12ar" 3 	[[#akk*+[[56	
 21
 DC 32s#   C)&C:D)
C7:
D
Dc                 Z   U R                  [        5         SSKJn  SSS5        [        R
                  " SS05      nU R                  [        R                  R                  5       nUR                  S5        SSS5        U R                  W5       nUR                  S5        SSS5        U R                  WR                  WR                  15        U R                  UR                  UR                  15        g! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f)zC
Ensure the wrapped referencing errors are hashable when possible.
r   r^   Nre   rf   rg   )rv   r   r   r_   r
   rj   rk   rl   r   rm   rn   assertInro   rw   s        r   (test_WrappedReferencingError_hashability9TestDeprecations.test_WrappedReferencingError_hashability   s     015 2 33V]4KL	{55BBCqr" D 12ar" 3 	akkAKK=1akkAKK=1 21
 DC 32s#   C:&DD:
D
D
D*c           	      t   SnU R                  [        U5       n " S S[        R                  5      nSSS5        U R	                  WR
                  [        5        U R                  [        U5       n " S S[        R                  " 0 S95      nSSS5        g! , (       d  f       Nk= f! , (       d  f       g= f)a+  
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                       \ rS rSrSrg)=TestDeprecations.test_Validator_subclassing.<locals>.Subclassi   N__name__
__module____qualname____firstlineno____static_attributes__r       r   Subclassr         r   r   Nc                       \ rS rSrSrg)DTestDeprecations.test_Validator_subclassing.<locals>.AnotherSubclassi  r   Nr   r   r   r   AnotherSubclassr     r   r   r   )meta_schema)r   r   r
   rj   r   r   r   create)r   r   r   r   r   s        r   test_Validator_subclassing+TestDeprecations.test_Validator_subclassing   s     6""#5w?1:::  @ 	X.""#5w?1*"3"3"C  @? @? @?s   B1B)
B&)
B7c                 *   U R                  [        R                  R                  SS5        SnU R	                  [
        U5       n[        R                  " S5        SSS5        U R                  WR                  [        5        g! , (       d  f       N/= f)zL
As of v4.14.0, FormatChecker.cls_checks is deprecated without
replacement.
boomNzFormatChecker.cls_checks )

addCleanupr   checkerspopr   r   
cls_checksr   r   r   )r   r   r   s      r   test_FormatChecker_cls_checks.TestDeprecations.test_FormatChecker_cls_checks  sl     	..22FDA-""#5w?1$$V, @ 	X. @?s   B
Bc                    SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  R                  5        U R                  WR                  [        5        SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  R                  5        U R                  UR                  [        5        SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R                  R                  5        U R                  UR                  [        5        S	nU R                  [        U5       nSS
KJn  SSS5        U R	                  W[
        R                   R                  5        U R                  UR                  [        5        SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R$                  R                  5        U R                  UR                  [        5        SnU R                  [        U5       nSSKJn  SSS5        U R	                  W[
        R(                  R                  5        U R                  UR                  [        5        U R+                  [,        5         SSKJn	  SSS5        g! , (       d  f       GN= f! , (       d  f       GNT= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN7= f! , (       d  f       N= f! , (       d  f       g= f)zo
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)r   r   r   r   assertIsr
   rj   FORMAT_CHECKERr   r   r   r   Draft201909Validatorr   rI   r   Draft6Validatorr   Draft4Validatorr   Draft3Validatorrk   ImportErrorr   )
r   r   r   r   r   r   r   r   r   r   s
             r   test_draftN_format_checker+TestDeprecations.test_draftN_format_checker  sn    H""#5w?1= @ 	&++::	
 	X.G""#5w?1= @ 	&++::	
 	X.B""#5w?18 @ 	!&&55	
 	X.B""#5w?18 @ 	!&&55	
 	X.B""#5w?18 @ 	!&&55	
 	X.B""#5w?18 @ 	!&&55	
 	X.{+; ,+w @? @? @? @? @? @? ,+sS   K
K;K0,LLL&<L7
K
K-0
K?
L
L#&
L47
Mc                    SnU R                  [        U5       nSSKn[        R                  " UR
                  5        SSS5        U R                  WR                  [        R                  5        g! , (       d  f       N9= f)z8
As of v4.17.0, importing jsonschema.cli is deprecated.
z5The jsonschema CLI is deprecated and will be removed r   N)	r   r   jsonschema.clir   reloadclir   r   r   )r   r   r   r   s       r   test_import_cli TestDeprecations.test_import_clid  s^    
 J""#5w?1!Z^^, @ 	Y%7%78	 @?s   %A11
A?c                     [         R                  " [        R                  SS/SS9nU R	                  SUR
                  5        g)z2
As of v4.17.0, the jsonschema CLI is deprecated.
z-mr   T)capture_outputs!   The jsonschema CLI is deprecated N)
subprocessrunsys
executabler|   stderr)r   processs     r   test_cliTestDeprecations.test_clip  s8    
 ..^^T<0
 	:GNNKr   c                   ^ ^ SnSSSS000mS[         R                  ;   a<  T R                  [         R                  R                  S[         R                  S   5        S[         R                  S'   [        UU 4S j5       n[
        R                  " S	U05      nS
n[        R                  R                  [        R                  SUS9nU   T R                  [        U5         T R                  UR                  0 5      UR                  S5      4S5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)zG
Automatic retrieval of remote references is deprecated as of v4.18.0.
zhttp://bar#/$defs/bazz$defsbazrG   integerrequestsNc              3     >#    TR                  U [        R                  R                  5        TR	                  U R
                  S5        U R                  5       u  u  pTR	                  UR                  5       S5        TR	                  US5        [        [        R                  " T5      R                  S5      5      v   g 7f)Nz
http://barz
user-agentz.python-jsonschema (deprecated $ref resolution)utf8)rV   urllibrequestRequestr   full_urlheader_itemslowerr   jsondumpsencode)r   headerr5   schemar   s      r   fake_urlopenFTestDeprecations.test_automatic_remote_retrieval.<locals>.fake_urlopen  s     !!'6>>+A+ABW--|<  '335OVV\\^\:G $**V,33F;<<s   B>Cre   z+Automatically retrieving remote references urlopen)new%   )FT)r   modulesr   __setitem__r   r
   rj   r   patchobjectr   r   r   r   r   rJ   )r   rh   r   rL   r   r   r   s   `     @r   test_automatic_remote_retrieval0TestDeprecations.test_automatic_remote_retrieval{  s    &EFI#678$OO''S[[5L #'J		= 
	= 33VSMB	?

!!&..)!ND))*<gF##B'););B)?@ GUUFFUUs$   	D5 3D$D5$
D2	.D55
Er   N)r   r   r   r   r   r$   r(   r,   r0   r6   r<   rD   rN   rS   rW   r[   rb   rs   ry   r}   r   r   r   r   r   r   r   r   r   r   r   r      ss    
//////////
///&
$
,2$./C<J
9	L$r   r   )
contextlibr   ior   unittestr   r   importlib.metadatar   r   r   r   urllib.requestr   referencing.exceptionsrl   r   r   r   r	   r
   r   r   r   r   <module>r      s4    %  #    
   G GPx Pr   