
    Mh=                         d dl mZ d dlmZ d dlmZmZ d dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlmZmZmZmZ  G d de          ZdS )    )contextmanager)BytesIO)TestCasemockN)FormatChecker
exceptions	protocols
validatorsc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestDeprecationsc                 "   d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j                            d                     |                     |j        t                     dS )zY
        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       b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jsonschema/tests/test_deprecations.pytest_versionzTestDeprecations.test_version   s    
 C""#5w?? 	/1......	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	i&8&@&@&N&NOOOX.....   155c                     d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j                   |                     |j        t                     dS )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_ErrorTreez*TestDeprecations.test_validators_ErrorTree   s     G""#5w?? 	81777777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	J$8999X.....r   c                     d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j                   |                     |j        t                     dS )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 r   r   N)r   r   r   r    r   r   r   r   r"   s       r   test_import_ErrorTreez&TestDeprecations.test_import_ErrorTree)   s     N""#5w?? 	-1,,,,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	J$8999X.....r   c                 r   t          j        ddg          }t          j                    }t          j        |g          }d}|                     t          |          5 }||d<   ddd           n# 1 swxY w Y   |                     |d         |           |                     |j        t                     dS )zM
        As of v4.20.0, setting items on an ErrorTree is deprecated.
        z
some errorfoo)path)errorszErrorTree.__setitem__ is N)r   ValidationErrorr    r   r   r   r   r   )r   etreesubtreer   r   s         r   test_ErrorTree_setitemz'TestDeprecations.test_ErrorTree_setitem6   s    
 &|5'BBB#%%&qc222-""#5w?? 	"1!DK	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	eg...X.....s   A00A47A4c                     d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j                   |                     |j        t                     dS )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   r0   r   r   r   r   )r   r   r   r0   s       r   test_import_FormatErrorz(TestDeprecations.test_import_FormatErrorF   s     P""#5w?? 	/1......	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	j&<===X.....r   c                     d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j                   |                     |j        t                     dS )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)r   r   r   r3   r   r	   r   r   )r   r   r   r3   s       r   test_import_Validatorz&TestDeprecations.test_import_ValidatorS   s     N""#5w?? 	-1,,,,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	I$7888X.....r   c                    d}|                      t          |          5 }t          j        }ddd           n# 1 swxY w Y   |                     |t          j                   |                     |j        t                     dS )za
        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_validatorsz+TestDeprecations.test_validators_validators`   s     M""#5w?? 	*1)E	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	
 6777X.....   7;;c                    d}|                      t          |          5 }t          j        }ddd           n# 1 swxY w Y   |                     |t          j                   |                     |j        t                     dS )zc
        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   r7   s       r   test_validators_meta_schemasz-TestDeprecations.test_validators_meta_schemasm   s     O""#5w?? 	,1+E	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	
 8999X.....r:   c                 J   t           j                            i           }d}|                     t          |          5 }|                    d          5  	 ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                     |j        t                     dS )zC
        As of v4.0.0, RefResolver.in_scope is deprecated.
        z.jsonschema.RefResolver.in_scope is deprecated r'   N)	r
   _RefResolverfrom_schemar   r   in_scoper   r   r   )r   resolverr   r   s       r   test_RefResolver_in_scopez*TestDeprecations.test_RefResolver_in_scopez   s   
 *66r::B""#5w?? 	1""5))                	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	X.....s5   A8A!A8!A%	%A8(A%	)A88A<?A<c                 2   t          j        i           }d}|                     t          |          5 }|                    dddi          }ddd           n# 1 swxY w Y   |                     |           |                     |j        t                     dS )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'   typenumberN)	r
   Draft7Validatorr   r   is_validassertFalser   r   r   )r   	validatorr   r   results        r   %test_Validator_is_valid_two_argumentsz6TestDeprecations.test_Validator_is_valid_two_arguments   s     .r22	I""#5w?? 	C1''/ABBF	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	   X.....s   AAAc                 B   t          j        i           }d}|                     t          |          5 }|                    dddi          \  }ddd           n# 1 swxY w Y   |                     |j        d           |                     |j        t                     dS )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'   rF   rG   N)	r
   rH   r   r   iter_errorsr   rK   r   r   )r   rK   r   r   errors        r   (test_Validator_iter_errors_two_argumentsz9TestDeprecations.test_Validator_iter_errors_two_arguments   s     .r22	L""#5w?? 	F1**5682DEEFE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	&111X.....s   AA Ac                 "   t          j        i           }d}|                     t          |          5 }|                     |j        t           j                   ddd           n# 1 swxY w Y   |                     |j        t                     dS )zL
        As of v4.18.0, accessing Validator.resolver is deprecated.
        z&Accessing Draft7Validator.resolver is N)
r
   rH   r   r   assertIsInstancerC   r@   r   r   r   )r   rK   r   r   s       r   test_Validator_resolverz(TestDeprecations.test_Validator_resolver   s    
 .r22	:""#5w?? 	O1!!)"4j6MNNN	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	X.....s   &A$$A(+A(c                 n   d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |j        t                     |                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |j        t                     dS )zA
        As of v4.18.0, RefResolver is fully deprecated.
        z$jsonschema.RefResolver is deprecatedr   )RefResolverN)r   r   r   rV   r   r   r   r!   )r   r   r   rV   s       r   test_RefResolverz!TestDeprecations.test_RefResolver   s5   
 9""#5w?? 	/1......	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/X...""#5w?? 	:1999999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:X.....s   1557B

BBc                    d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j                   |                     |j        t                     |                      t          |          5 }ddl	m} ddd           n# 1 swxY w Y   |                     |t
          j                   |                     |j        t                     dS )z
        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   rZ   r   r   _RefResolutionErrorr   r   jsonschema.exceptions)r   r   r   rZ   s       r   test_RefResolutionErrorz(TestDeprecations.test_RefResolutionError   s~    K""#5w?? 	61555555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	+Z-KLLLX...""#5w?? 	A1@@@@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	+Z-KLLLX.....s   155B**B.1B.c                 v   t          j        ddi          }|                     t          j        j                  5 }|                    d           ddd           n# 1 swxY w Y   t          j                            d          }|                     |j        t          |j                  f|df           dS )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)refUnresolvable: urn:nothing)
r
   Draft202012ValidatorassertRaisesreferencingr   Unresolvablevalidater   	exceptionstr)r   rK   r+   expecteds       r   #test_catching_Unresolvable_directlyz4TestDeprecations.test_catching_Unresolvable_directly   s     3V]4KLL	{5BCC 	#qr"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# )66=6II[#ak**+23	
 	
 	
 	
 	
s   AA!$A!c                 4   |                      t                    5  ddlm} ddd           n# 1 swxY w Y   t	          j        ddi          }|                     t          j        j	                  5 }|
                    d           ddd           n# 1 swxY w Y   |                     |          5 }|
                    d           ddd           n# 1 swxY w Y   |                     |j        t          |j                  f|j        df           dS )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   rY   Nr_   r`   ra   rc   )assertWarnsr   r   rZ   r
   rd   re   rf   r   rg   rh   r   ri   rj   r   rZ   rK   ur+   s        r   1test_catching_Unresolvable_via_RefResolutionErrorzBTestDeprecations.test_catching_Unresolvable_via_RefResolutionError   s    011 	6 	6555555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 3V]4KLL	{5BCC 	#qr"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 122 	#ar"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	[#ak**+[56	
 	
 	
 	
 	
0   .223BBB5CCCc                 L   |                      t                    5  ddlm} ddd           n# 1 swxY w Y   t	          j        ddi          }|                     t          j        j	                  5 }|
                    d           ddd           n# 1 swxY w Y   |                     |          5 }|
                    d           ddd           n# 1 swxY w Y   |                     |j        |j        h           |                     |j        |j        h           dS )zS
        Ensure the wrapped referencing errors are hashable when possible.
        r   rY   Nr_   r`   ra   )rn   r   r   rZ   r
   rd   re   rf   r   rg   rh   assertInri   ro   s        r   (test_WrappedReferencingError_hashabilityz9TestDeprecations.test_WrappedReferencingError_hashability   s    011 	6 	6555555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 3V]4KLL	{5BCC 	#qr"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 122 	#ar"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	akAK=111akAK=11111rr   c                    d}|                      t          |          5 } G d dt          j                  }ddd           n# 1 swxY w Y   |                     |j        t                     |                      t          |          5 } G d dt          j        i                     }ddd           dS # 1 swxY w Y   dS )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                       e Zd ZdS )=TestDeprecations.test_Validator_subclassing.<locals>.SubclassN__name__
__module____qualname__     r   Subclassrx             r~   r   Nc                       e Zd ZdS )DTestDeprecations.test_Validator_subclassing.<locals>.AnotherSubclassNry   r}   r~   r   AnotherSubclassr     r   r~   r   )meta_schema)r   r   r
   rd   r   r   r   create)r   r   r   r   r   s        r   test_Validator_subclassingz+TestDeprecations.test_Validator_subclassing
  si    6""#5w?? 	1    ::   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	X...""#5w?? 	1    *"3"C"C"C   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s#   AA
A	"B88B<?B<c                 $   |                      t          j        j        dd           d}|                     t
          |          5 }t          j        d           ddd           n# 1 swxY w Y   |                     |j        t                     dS )zd
        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_checksz.TestDeprecations.test_FormatChecker_cls_checks!  s     	.2FDAAA-""#5w?? 	-1$V,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	X.....s   A%%A),A)c                 x   d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j        j                   |                     |j	        t                     d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j        j                   |                     |j	        t                     d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j        j                   |                     |j	        t                     d	}|                      t          |          5 }dd
lm} ddd           n# 1 swxY w Y   |                     |t
          j        j                   |                     |j	        t                     d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j        j                   |                     |j	        t                     d}|                      t          |          5 }ddlm} ddd           n# 1 swxY w Y   |                     |t
          j        j                   |                     |j	        t                     |                     t,                    5  ddlm}	 ddd           dS # 1 swxY w Y   dS )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)r   r   r   r   assertIsr
   rd   FORMAT_CHECKERr   r   r   r   Draft201909Validatorr   rH   r   Draft6Validatorr   Draft4Validatorr   Draft3Validatorre   ImportErrorr   )
r   r   r   r   r   r   r   r   r   r   s
             r   test_draftN_format_checkerz+TestDeprecations.test_draftN_format_checker/  s    H""#5w?? 	>1======	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	&+:	
 	
 	
 	X...G""#5w?? 	>1======	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	&+:	
 	
 	
 	X...B""#5w?? 	91888888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	!&5	
 	
 	
 	X...B""#5w?? 	91888888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	!&5	
 	
 	
 	X...B""#5w?? 	91888888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	!&5	
 	
 	
 	X...B""#5w?? 	91888888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	!&5	
 	
 	
 	X...{++ 	< 	<;;;;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<sx   155B11B58B5D11D58D5F11F58F5H11H58H5J11J58J5L//L36L3c                     d}|                      t          |          5 }ddl}t          j        |j                   ddd           n# 1 swxY w Y   |                     |j        t          j                   dS )zH
        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_cliz TestDeprecations.test_import_clit  s    
 J""#5w?? 	-1!!!!Z^,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	Y%788888s   AAAc                     t          j        t          j        ddgdd          }|                     d|j                   dS )zB
        As of v4.17.0, the jsonschema CLI is deprecated.
        z-mr   T)capture_outputchecks!   The jsonschema CLI is deprecated N)
subprocessrunsys
executablert   stderr)r   processs     r   test_clizTestDeprecations.test_cli  sK    
 .^T<0
 
 

 	:GNKKKKKr~   c                     d}ddddiiidt           j        v r6                     t           j        j        dt           j        d                    dt           j        d<   t           fd            }t          j        d	|i          }d
}t          j        	                    t          j        d|          }|5                       t          |          5                       |                    i           |                    d          fd           ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )zW
        Automatic retrieval of remote references is deprecated as of v4.18.0.
        zhttp://bar#/$defs/bazz$defsbazrF   integerrequestsNc              3     K                        | t          j        j                                       | j        d           |                                 \  \  }}                    |                                d                               |d           t          t          j
                                      d                    V  d S )Nz
http://barz
user-agentz.python-jsonschema (deprecated $ref resolution)utf8)rS   urllibrequestRequestr   full_urlheader_itemslowerr   jsondumpsencode)r   headerr8   schemar   s      r   fake_urlopenzFTestDeprecations.test_automatic_remote_retrieval.<locals>.fake_urlopen  s      !!'6>+ABBBW-|<<<  '3355OVUV\\^^\:::G   $*V,,33F;;<<<<<<<r~   r_   z+Automatically retrieving remote references urlopen)new%   )FT)r   modulesr   __setitem__r   r
   rd   r   patchobjectr   r   r   r   r   rI   )r   rb   r   rK   r   r   r   s   `     @r   test_automatic_remote_retrievalz0TestDeprecations.test_automatic_remote_retrieval  s    &EFI#678$$OO'S[5L   #'J		= 	= 	= 	= 	= 
	= 3VSMBB	?
!!&.)!NN 	 	D))*<gFF 	 	##B''););B)?)?@  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s6   9D8?D D8 D$	$D8'D$	(D88D<?D<N)rz   r{   r|   r   r#   r%   r.   r1   r4   r9   r>   rD   rM   rQ   rT   rW   r]   rl   rq   ru   r   r   r   r   r   r   r}   r~   r   r   r      st       
/ 
/ 
// / // / // / / / / // / // / // / // / // / // / /
/ 
/ 
// / // / /&
 
 
$
 
 
,2 2 2$  ./ / /C< C< C<J
9 
9 
9
L 
L 
L$ $ $ $ $r~   r   )
contextlibr   ior   unittestr   r   importlib.metadatar   r   r   r   urllib.requestr   referencing.exceptionsrf   r   r   r   r	   r
   r   r}   r~   r   <module>r      s    % % % % % %       # # # # # # # #          



         G G G G G G G G G G G Ga a a a ax a a a a ar~   