
    gW                      d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZmZ d dl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mZmZ d dlmZ d d	lZd dlmZm Z m!Z!m"Z"m#Z# d Z$ G d de      Z% G d de      Z& G d de      Z' G d d      Z( G d de(      Z) G d d      Z* G d de*e)e      Z+ G d de*e)e      Z, G d de)e      Z- G d  d!e)e      Z. G d" d#e)e      Z/ G d$ d%e)e      Z0 G d& d'e      Z1 G d( d)e      Z2 G d* d+e      Z3 G d, d-e      Z4 G d. d/e      Z5 G d0 d1e      Z6d2 Z7e G d3 d4             Z8e G d5 d6             Z9y	)7    )annotations)deque
namedtuple)contextmanager)Decimal)BytesIO)Any)TestCasemock)pathname2urlN)definefield)DRAFT202012)FormatCheckerTypeChecker
exceptions	protocols
validatorsc              #  l   K   |D ]+  }|j                  dd       t        j                  di | - y w)NmessagezYou told me to fail! )
setdefaultr   ValidationError)	validatorerrorsinstanceschemaeachs        U/var/www/openai/venv/lib/python3.12/site-packages/jsonschema/tests/test_validators.pyfailr       s3     	#9:((0400 s   24c                      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y)TestCreateAndExtendc                   | j                  | j                  t        j                  t	        t        j                               | j                  | j                  t        j
                  t	        t        j
                               ddi| _        dt        i| _        t               | _	        t        j                  | j                  | j                  | j                        | _        y )N$idzsome://meta/schemar    )meta_schemar   type_checker)
addCleanupassertEqualr   _META_SCHEMASdict_VALIDATORSr%   r    r   r&   create	Validatorselfs    r   setUpzTestCreateAndExtend.setUp$   s    $$))*	

 	""''(	
 "#78!4.'M#**((**
    c                    | j                  | j                  j                  | j                  j                  | j                  j                  f| j
                  | j                  | j                  f       y N)r(   r-   
VALIDATORSMETA_SCHEMATYPE_CHECKERr   r%   r&   r.   s    r   
test_attrszTestCreateAndExtend.test_attrs9   s\    ))**++
   !!
	
r1   c                b    dg i}| j                  | j                  |      j                  |       y )Nr    )r(   r-   r   r/   r   s     r   	test_initzTestCreateAndExtend.test_initF   s*    "/66?r1   c                    dg i}| j                  |      }t        |j                  d            }| j                  |g        y )Nr    hello)r-   listiter_errorsr(   r/   r   r   r   s       r   test_iter_errors_successfulz/TestCreateAndExtend.test_iter_errors_successfulJ   s>    "NN6*	i++G45$r1   c           
     P   dddigi}| j                  |      }t        j                  dd|dddigt        dg            }t	        |j                  d            }| j                  t        |      d       | j                  |d   j                         |j                                y )Nr    r   zWhoops!goodbye)r   r   r   validator_valueschema_path   r   )	r-   r   r   r   r=   r>   r(   len	_contents)r/   r   r   expected_errorr   s        r   test_iter_errors_one_errorz.TestCreateAndExtend.test_iter_errors_one_errorQ   s    Iy123NN6*	#33'34vh
 i++I67Va(,,.0H0H0JKr1   c                    dddidddddigi}| j                  |      }t        |j                  d            }| j                  t	        |      d	       y )
Nr    r   FirstzSecond!asdf)r   r   ThirdrB      )r-   r=   r>   r(   rF   r?   s       r    test_iter_errors_multiple_errorsz4TestCreateAndExtend.test_iter_errors_multiple_errorsb   sb    G$%F;G$
 NN6*	i++I67Va(r1   c                N   t        j                  ddid      }| j                  t         j                  j                  d       | j                  t         j
                  j                  d       | j                  |j                  d       | j                  |j                  d       y )Nr$   	something
my versionr%   versionMyVersionValidator)	r   r,   r'   r)   popr+   r(   __name____qualname__r/   r-   s     r   .test_if_a_version_is_provided_it_is_registeredzBTestCreateAndExtend.test_if_a_version_is_provided_it_is_registeredo   s    %%, 
	 	
0044kB
..22LA++-AB//1EFr1   c                    t        j                  ddid      }| j                  t         j                  j                  d       | j                  t         j
                  j                  d       | j                  t         |i             d       y )Nr$   rQ   rR   rS   z2MyVersionValidator(schema={}, format_checker=None))r   r,   r'   r)   rV   r+   r(   reprrY   s     r   	test_reprzTestCreateAndExtend.test_repry   sp    %%, 
	 	
0044kB
..22LA2@	
r1   c                H   t        j                  ddid      }| j                  t         j                  j                  d       | j                  t         j
                  j                  d       | j                  t         |dt        t        d            i            d       y )Nr$   rQ   rR   rS   ai  zNMyVersionValidator(schema={'a': [0, 1, 2, 3, 4, 5, ...]}, format_checker=None))
r   r,   r'   r)   rV   r+   r(   r\   r=   rangerY   s     r   test_long_reprz"TestCreateAndExtend.test_long_repr   s    %%, 
	 	
0044kB
..22LACeDk!2345'	
r1   c                r    t        j                  i       }| j                  t         |i             d       y )Nr%   z)Validator(schema={}, format_checker=None))r   r,   r(   r\   rY   s     r   test_repr_no_versionz(TestCreateAndExtend.test_repr_no_version   s/    %%"5	27	
r1   c                   t        j                  ddid      }| j                  t         j                  j                  d       | j                  t         j
                  j                  d       | j                  |j                  d       y )Nr$   rQ   zfoo-barrS   FooBarValidator)r   r,   r'   r)   rV   r+   r(   rX   rY   s     r   -test_dashes_are_stripped_from_validator_nameszATestCreateAndExtend.test_dashes_are_stripped_from_validator_names   sj    %%,
	 	
0044kB
..22I>//1BCr1   c                    t        t        j                        }t        j                  ddi       | j	                  t        j                  |       y )Nidrc   )r*   r   r)   r,   r(   )r/   originals     r   6test_if_a_version_is_not_provided_it_is_not_registeredzJTestCreateAndExtend.test_if_a_version_is_not_provided_it_is_not_registered   s:    
001tTl3118<r1   c                *   d}d|i}t        j                  |dd        | j                  t         j                  j                  |       | j                  t         j
                  j                  d       | j                  |t         j                         y )Nmeta schema idri   rR   c                &    | j                  dd      S Nri    getss    r   <lambda>zMTestCreateAndExtend.test_validates_registers_meta_schema_id.<locals>.<lambda>       AEE$Or1   r%   rT   id_ofr   r,   r'   r)   rV   r+   assertInr/   meta_schema_keymy_meta_schemas      r   'test_validates_registers_meta_schema_idz;TestCreateAndExtend.test_validates_registers_meta_schema_id   sr    *0& +	

 	
0044oF
..22LAoz'?'?@r1   c                &   d}d|i}t        j                  |d       | j                  t         j                  j                  |       | j                  t         j
                  j                  d       | j                  |t         j                         y )Nmeta schema $idr$   rR   rS   ry   r{   s      r   .test_validates_registers_meta_schema_draft6_idzBTestCreateAndExtend.test_validates_registers_meta_schema_draft6_id   so    +1& 	
 	
0044oF
..22LAoz'?'?@r1   c                    t        j                  i d      | j                  t        fddg fddddd	i fd
fD                     y )Nr   r%   r   c              3  V   K   | ]   \  }} i       j                  ||        " yw))r   typeN)is_type).0r   r   r-   s      r   	<genexpr>z@TestCreateAndExtend.test_create_default_types.<locals>.<genexpr>   s5      'ND( "%%xd%C's   &)array)booleanT)integer   )nullN)numberg      (@object)stringfoo)r   r,   
assertTrueallrY   s    @r   test_create_default_typesz-TestCreateAndExtend.test_create_default_types   sW    %%"D	  bM%#"$rN%' 	
r1   c                R   t        j                  t         j                  j                  d   di id      }|j	                  ddi       | j                  t        j                        5  |j	                  i        ddd        |ddi      j                  d       y# 1 sw Y   #xY w)zq
        One can create a validator class whose metaschema uses a different
        dialect than itself.
        r$   const)$schemanotrc   r   barN)	r   r,   Draft202012Validatorr5   check_schemaassertRaisesr   SchemaErrorvalidater/   NoEmptySchemasValidators     r   +test_check_schema_with_different_metaschemaz?TestCreateAndExtend.test_check_schema_with_different_metaschema   s     #-"3"3%::FFuM}#
 	 ,,eU^<z556#004 7 	 /88? 76s   )BB&c                    t        j                  dddigidt        i      }| j                  t        j
                        5  |j                  i        ddd       y# 1 sw Y   yxY w)z
        A validator whose metaschema doesn't declare $schema defaults to its
        own validation behavior, not the latest "normal" specification.
        r    r   zMeta schema whoops!r   N)r   r,   r    r   r   r   r   r   s     r   <test_check_schema_with_different_metaschema_defaults_to_selfzPTestCreateAndExtend.test_check_schema_with_different_metaschema_defaults_to_self   s]     #-"3"39.C"D!EF~#
 z556#004 766s   AA&c                   t        | j                  j                        }t               }t	        j
                  | j                  d|i      }| j                  |j                  |j                  |j                  | j                  j                  ft        ||      | j                  j                  | j                  j                  |f       y )Nnew)r   )r   )	r*   r-   r4   r   r   extendr(   r5   r6   )r/   rj   r   Extendeds       r   test_extendzTestCreateAndExtend.test_extend   s    112h$$NNs|
 	##$$%%))	 X3'**++		
r1   c                N     fd}d}d|d}t        j                  | j                    j                  |      } j                  |j	                  |j
                        |       t        j                  |      } j                  |j	                  |j
                        |       y)zK
        Extending a validator preserves its notion of schema IDs.
        c                Z    | j                  dj                  j                  |             S )N__test__)rr   r-   ID_OF)r   r/   s    r   rx   z3TestCreateAndExtend.test_extend_idof.<locals>.id_of  s#    ::j$..*>*>v*FGGr1   zthe://correct/id/zthe://wrong/id/)r$   r   )r%   r   r&   rx   N)r   r,   r&   r(   r   r5   r   )r/   rx   
correct_idr%   OriginalDeriveds   `     r   test_extend_idofz$TestCreateAndExtend.test_extend_idof
  s    	H(
$"
 $$#**	
 	(<(<=zJ##H-w':':;ZHr1   c                   dddiiddd}t        j                  |      }| j                  |j                  d             t        j                  t         j                        }| j                   ||      j                  d             y)	zV
        Extending a validator preserves its notion of applicable validators.
        testr   r   z#/$defs/testrE   )$defs$refmaximum%   N)r   Draft4Validatorr   is_validr   )r/   r   draft4r   s       r   !test_extend_applicable_validatorsz5TestCreateAndExtend.test_extend_applicable_validators   sv     vx01"
 ++F3+,##J$>$>?0045r1   N)rW   
__module__rX   r0   r7   r:   r@   rI   rO   rZ   r]   ra   rd   rg   rk   r~   r   r   r   r   r   r   r   r   r1   r   r"   r"   #   sn    
*
@%L")G



D=
AA
"@&5
,I,6r1   r"   c                  h   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 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. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<y;)<TestValidationErrorMessagesc                :   |j                  dt        j                        }|j                  |        ||g|i |}t	        |j                  |            }| j                  |d|       | j                  t        |      dd|       |d   j                  S )NclszNo errors were raised for )msgrE   z"Expected exactly one error, found r   )
rV   r   _LATEST_VERSIONr   r=   r>   r   r(   rF   r   )r/   r   r   argskwargsr   r   r   s           r   message_forz'TestValidationErrorMessages.message_for3  s    jj
 : :; 000	i++H56&@$MNK4VJ? 	 	

 ay   r1   c                R    | j                  dddi      }| j                  |d       y NrE   r   r   r   r   1 is not of type 'string'r   r(   r/   r   s     r   test_single_type_failurez4TestValidationErrorMessages.test_single_type_failure@  s-    ""Avx6H"I"=>r1   c                T    | j                  dddgi      }| j                  |d       y r   r   r   s     r   test_single_type_list_failurez9TestValidationErrorMessages.test_single_type_list_failureD  s/    ""Avz6J"K"=>r1   c                h    d}| j                  ddt        |      i      }| j                  |d       y )N)r   r   rE   r   r   z#1 is not of type 'string', 'object')r   r=   r(   )r/   typesr   s      r   test_multiple_type_failurez6TestValidationErrorMessages.test_multiple_type_failureH  s6    """AvtE{6K"L"GHr1   c                |    ddddgi}| j                  d|t        j                        }| j                  |d       y )Nr   FoorN   )nameminimumrE   r   r   r   z1 is not of type 'Foo'r   r   Draft3Validatorr(   r/   r   r   s      r   #test_object_with_named_type_failurez?TestValidationErrorMessages.test_object_with_named_type_failureM  sK    Ea89:""** # 

 	":;r1   c                R    | j                  dddi      }| j                  |d       y )NrE   r      r   z1 is less than the minimum of 2r   r   s     r   test_minimumz(TestValidationErrorMessages.test_minimumV  s,    ""Ay!n"E"CDr1   c                R    | j                  dddi      }| j                  |d       y )NrE   r   r   r   z"1 is greater than the maximum of 0r   r   s     r   test_maximumz(TestValidationErrorMessages.test_maximumZ  s,    ""Ay!n"E"FGr1   c                    d\  }}d||ii}| j                  ddi|t        j                        }| j                  |d       y Nr   r   dependenciesr   r   r   z'foo' is a dependency of 'bar'r   r/   dependonr   r   s        r    test_dependencies_single_elementz<TestValidationErrorMessages.test_dependencies_single_element^  sT    !
 62,/""QZ** # 

 	"BCr1   c                    dddigi}| j                  dd|git        j                        }| j                  |d       y )Nr   r   rN   rE   r   z+1 is not of type {'type': [{'minimum': 3}]}r   )r/   r   r   s      r   -test_object_without_title_type_failure_draft3zITestValidationErrorMessages.test_object_without_title_type_failure_draft3h  sT    )Q()""TF#** # 

 	9	
r1   c                    d\  }}d||gii}| j                  ddi|t        j                        }| j                  |d       y r   r   r   s        r   test_dependencies_list_draft3z9TestValidationErrorMessages.test_dependencies_list_draft3t  V    !
 6B4.1""QZ** # 

 	"BCr1   c                    d\  }}d||gii}| j                  ddi|t        j                        }| j                  |d       y r   r   r   Draft7Validatorr(   r   s        r   test_dependencies_list_draft7z9TestValidationErrorMessages.test_dependencies_list_draft7~  r   r1   c                t    | j                  dgg ddt        j                        }| j                  d|       y )Nr   FitemsadditionalItemsr   z(2 was unexpected)r   r   r   rz   r   s     r   #test_additionalItems_single_failurez?TestValidationErrorMessages.test_additionalItems_single_failure  s>    ""SE:** # 

 	*G4r1   c                v    | j                  g dg ddt        j                        }| j                  d|       y )NrE   r   rN   Fr   r   z(1, 2, 3 were unexpected)r   r   s     r   &test_additionalItems_multiple_failureszBTestValidationErrorMessages.test_additionalItems_multiple_failures  s<    ""E:** # 

 	17;r1   c                ^    d}ddi}| j                  |di|      }| j                  d|       y )Nr   additionalPropertiesFr   r   z('foo' was unexpected)r   rz   )r/   
additionalr   r   s       r   (test_additionalProperties_single_failurezDTestValidationErrorMessages.test_additionalProperties_single_failure  s9    
(%0""ZOF"K.8r1   c                    ddi}| j                  t        j                  ddg      |      }| j                  t	        d      |       | j                  t	        d      |       | j                  d|       y )Nr   Fr   r   r   zwere unexpected))r   r*   fromkeysrz   r\   r   s      r   +test_additionalProperties_multiple_failureszGTestValidationErrorMessages.test_additionalProperties_multiple_failures  si    (%0""]]E5>2 # 

 	d5k7+d5k7+('2r1   c                Z    ddi}| j                  ddi|      }| j                  d|       y )Nr   r   r   r   r   z12 was expectedr   r   s      r   
test_constz&TestValidationErrorMessages.test_const  s;    2""U^ # 
 	'1r1   c                ~    dddii}| j                  di g g|t        j                        }| j                  |d       y )Ncontainsr   r   r   r   z4None of [2, {}, []] are valid under the given schema)r   r   Draft6Validatorr(   r   s      r   test_contains_draft_6z1TestValidationErrorMessages.test_contains_draft_6  sP    wm,""R[** # 

 	B	
r1   c                   t        d      } |j                  d      d        ddi}| j                  d||      }| j                  t	        d      |       | j                  t	        d      |       | j                  d|       y )	Nr   )formatsthingc                     yNFr   )values    r   ru   zQTestValidationErrorMessages.test_invalid_format_default_message.<locals>.<lambda>  s    er1   formatbla)r   r   format_checkerzis not a)r   checksr   rz   r\   )r/   checkerr   r   s       r   #test_invalid_format_default_messagez?TestValidationErrorMessages.test_invalid_format_default_message  s|    +w 34G$""" # 
 	d5k7+d7mW-j'*r1   c                   ddddiddidd}| j                  ddi|t        j                  	      }| j                  |d
j	                  t        d      t        d      t        d                   | j                  ddd|t        j                  	      }| j                  |dj	                  t        d      t        d      t        d      t        d                   y )Nr   Fr   r   )^abc$^def$)r   r   patternPropertieszebra{   r   z,{} does not match any of the regexes: {}, {}r  r  i  )r  fishz.{}, {} do not match any of the regexes: {}, {}r  )r   r   r   r(   r  r\   r   s      r   1test_additionalProperties_false_patternPropertieszMTestValidationErrorMessages.test_additionalProperties_false_patternProperties  s    "*/ &1 &1( ""s^** # 

 	:AAWtG}d7m	
 """C0** # 

 	<CCVd7mT']DM	
r1   c                N    | j                  dd      }| j                  |d       y )NrQ   Fr   z'False schema does not allow 'something'r   r   s     r   test_False_schemaz-TestValidationErrorMessages.test_False_schema  s0    ""  # 
 	"KLr1   c                R    | j                  dddi      }| j                  |d       y )NrN   
multipleOfr   r   z3 is not a multiple of 2r   r   s     r   test_multipleOfz+TestValidationErrorMessages.test_multipleOf  s5    "" !$ # 
 	"<=r1   c                R    | j                  g ddi      }| j                  |d       y )NminItemsr   r   z[] is too shortr   r   s     r   test_minItemsz)TestValidationErrorMessages.test_minItems  s,    ""B
A"G"34r1   c                V    | j                  g dddi      }| j                  |d       y )Nr   maxItemsr   r   z[1, 2, 3] is too longr   r   s     r   test_maxItemsz)TestValidationErrorMessages.test_maxItems  s,    ""Iz1o"N"9:r1   c                R    | j                  g ddi      }| j                  |d       y )Nr!  rE   r   z[] should be non-emptyr   r   s     r   test_minItems_1z+TestValidationErrorMessages.test_minItems_1   s,    ""B
A"G":;r1   c                V    | j                  g dddi      }| j                  |d       y )Nr   r$  r   r   z![1, 2, 3] is expected to be emptyr   r   s     r   test_maxItems_0z+TestValidationErrorMessages.test_maxItems_0  s,    ""Iz1o"N"EFr1   c                R    | j                  dddi      }| j                  |d       y )Nrp   	minLengthr   r   z'' is too shortr   r   s     r   test_minLengthz*TestValidationErrorMessages.test_minLength  s5    ""# # 
 	"34r1   c                R    | j                  dddi      }| j                  |d       y )Nabc	maxLengthr   r   z'abc' is too longr   r   s     r   test_maxLengthz*TestValidationErrorMessages.test_maxLength  s5    ""# # 
 	"56r1   c                R    | j                  dddi      }| j                  |d       y )Nrp   r+  rE   r   z'' should be non-emptyr   r   s     r   test_minLength_1z,TestValidationErrorMessages.test_minLength_1  s-    ""BQ7G"H":;r1   c                R    | j                  dddi      }| j                  |d       y )Nr.  r/  r   r   z'abc' is expected to be emptyr   r   s     r   test_maxLength_0z,TestValidationErrorMessages.test_maxLength_0  s-    ""E;:J"K"ABr1   c                R    | j                  i ddi      }| j                  |d       y )NminPropertiesr   r   z"{} does not have enough propertiesr   r   s     r   test_minPropertiesz.TestValidationErrorMessages.test_minProperties  s-    ""B7K"L"FGr1   c                Z    | j                  i i i dddi      }| j                  |d       y )N)r_   bcmaxPropertiesr   r   z3{'a': {}, 'b': {}, 'c': {}} has too many propertiesr   r   s     r   test_maxPropertiesz.TestValidationErrorMessages.test_maxProperties"  s?    ""BR0#Q' # 
 	A	
r1   c                R    | j                  i ddi      }| j                  |d       y )Nr6  rE   r   z{} should be non-emptyr   r   s     r   test_minProperties_1z0TestValidationErrorMessages.test_minProperties_1,  s-    ""B7K"L":;r1   c                V    | j                  ddiddi      }| j                  |d       y )NrE   r   r;  r   r   z{1: 2} is expected to be emptyr   r   s     r   test_maxProperties_0z0TestValidationErrorMessages.test_maxProperties_00  s9    ""V#Q' # 
 	"BCr1   c                \    | j                  g ddi i gd      }| j                  |d       y )N)rE   r   r   Fr   prefixItemsr   z1Expected at most 2 items but found 1 extra: 'foo'r   r   s     r   test_prefixItems_with_itemsz7TestValidationErrorMessages.test_prefixItems_with_items7  s<    """"B8< # 
 	?	
r1   c                \    | j                  g ddi i gd      }| j                  |d       y )NrE   r   r      FrB  r   z6Expected at most 2 items but found 2 extra: ['foo', 5]r   r   s     r   *test_prefixItems_with_multiple_extra_itemszFTestValidationErrorMessages.test_prefixItems_with_multiple_extra_itemsA  s<    ""%"B8< # 
 	D	
r1   c                R    | j                  dddi      }| j                  |d       y )Nbbbpatternz^a*$r   z'bbb' does not match '^a*$'r   r   s     r   test_patternz(TestValidationErrorMessages.test_patternK  s5    ""v& # 
 	"?@r1   c                V    | j                  g dddii      }| j                  |d       y )Nr  r   r   r   z3[] does not contain items matching the given schemar   r   s     r   test_does_not_containz1TestValidationErrorMessages.test_does_not_containR  s=    "" 23 # 
 	A	
r1   c                \    | j                  ddgddidd      }| j                  |d       y )	Nr   rE   r   r   r   r  minContainsr   MToo few items match the given schema (expected at least 2 but only 1 matched)r   r   s     r   test_contains_too_fewz1TestValidationErrorMessages.test_contains_too_few\  sC    ""QZ!' 21E # 
 	7	
r1   c                ^    | j                  ddgddiddd      }| j                  |d	       y )
Nr   rE   r   r   r      r  rQ  maxContainsr   rR  r   r   s     r   &test_contains_too_few_both_constrainedzBTestValidationErrorMessages.test_contains_too_few_both_constrainedg  sI    ""QZ#X.   # 
 		
r1   c                \    | j                  g dddidd      }| j                  |d       y )Nr   r   bazr   r   r   r  rW  r   :Too many items match the given schema (expected at most 2)r   r   s     r   test_contains_too_manyz2TestValidationErrorMessages.test_contains_too_manyv  s=    ""*!' 21E # 
 	H	
r1   c                b    | j                  dgdz  ddiddd      }| j                  |d	       y )
Nr   rG  r   r   r   rU  rV  r   z:Too many items match the given schema (expected at most 4)r   r   s     r   'test_contains_too_many_both_constrainedzCTestValidationErrorMessages.test_contains_too_many_both_constrained  sI    ""Wq[#X.   # 
 	H	
r1   c                R    | j                  dddi      }| j                  |d       y )NrN   exclusiveMinimumrG  r   z+3 is less than or equal to the minimum of 5r   r   s     r   test_exclusiveMinimumz1TestValidationErrorMessages.test_exclusiveMinimum  s8    ""&* # 
 	9	
r1   c                R    | j                  dddi      }| j                  |d       y )NrN   exclusiveMaximumr   r   z.3 is greater than or equal to the maximum of 2r   r   s     r   test_exclusiveMaximumz1TestValidationErrorMessages.test_exclusiveMaximum  s1    ""A7I16M"N<	
r1   c                T    | j                  i ddgi      }| j                  |d       y )Nrequiredr   r   z'foo' is a required propertyr   r   s     r   test_requiredz)TestValidationErrorMessages.test_required  s/    ""B
UG7L"M"@Ar1   c                \    | j                  di idddgii      }| j                  |d       y )Nr   dependentRequiredr   r   z'bar' is a dependency of 'foo'r   r   s     r   test_dependentRequiredz2TestValidationErrorMessages.test_dependentRequired  s@    ""R['%%)9: # 
 	"BCr1   c                T    | j                  i ddgi      }| j                  |d       y )NoneOfFr   z.{} is not valid under any of the given schemasr   r   s     r   test_oneOf_matches_nonez3TestValidationErrorMessages.test_oneOf_matches_none  s2    ""B%7I"J<	
r1   c                V    | j                  i dddgi      }| j                  |d       y )Nrn  Tr   z${} is valid under each of True, Truer   r   s     r   test_oneOf_matches_too_manyz7TestValidationErrorMessages.test_oneOf_matches_too_many  s1    ""B$7N"O"HIr1   c                \    ddd}| j                  ddg|      }| j                  |d       y )Nr   Fr   unevaluatedItemsr   r   r   z@Unevaluated items are not allowed ('foo', 'bar' were unexpected)r   r   s      r   test_unevaluated_itemsz2TestValidationErrorMessages.test_unevaluated_items  s7    !u=""UEN6"JN	
r1   c                X    ddd}| j                  d|      }| j                  |d       y )Nr   Frs  r   r   z'foo' is not of type 'array'r   r   s      r   &test_unevaluated_items_on_invalid_typezBTestValidationErrorMessages.test_unevaluated_items_on_invalid_type  s2    !u=""E&"A"@Ar1   c                l    dddiiddid}| j                  dddd|	      }| j                  |d
       y )Nr   r   r   r   r   
propertiesunevaluatedPropertiesr   rZ  r   z_Unevaluated properties are not valid under the given schema ('bar' was unevaluated and invalid)r   r   s      r   5test_unevaluated_properties_invalid_against_subschemazQTestValidationErrorMessages.test_unevaluated_properties_invalid_against_subschema  s_     68"45&-r]
 ""
  # 
 	2	
r1   c                ^    ddd}| j                  ddd|      }| j                  |d       y )	Nr   Fr   r{  r   r   r   r   r   zEUnevaluated properties are not allowed ('bar', 'foo' were unexpected)r   r   s      r   &test_unevaluated_properties_disallowedzBTestValidationErrorMessages.test_unevaluated_properties_disallowed  sI    "UC""  # 
 	-	
r1   c                X    ddd}| j                  d|      }| j                  |d       y )Nr   Fr~  r   r   z'foo' is not of type 'object'r   r   s      r   +test_unevaluated_properties_on_invalid_typezGTestValidationErrorMessages.test_unevaluated_properties_on_invalid_type  s2    "UC""E&"A"ABr1   c                ^    i gdd}| j                  g d|      }| j                  |d       y )NFrC  r   rZ  r   z9Expected at most 1 item but found 2 extra: ['bar', 'baz']r   r   s      r   test_single_itemz,TestValidationErrorMessages.test_single_item  s?    "$6""* # 
 	G	
r1   c                |    i gdd}| j                  g d|t        j                        }| j                  |d       y )NFr   r   r   r   r   z<Additional items are not allowed ('bar', 37 were unexpected)r   r   s      r   -test_heterogeneous_additionalItems_with_ItemszITestValidationErrorMessages.test_heterogeneous_additionalItems_with_Items  sH    4E:""'** # 

 	J	
r1   c                ^    i gdd}| j                  g d|      }| j                  |d       y )NFr  r  r   z6Expected at most 1 item but found 2 extra: ['bar', 37]r   r   s      r   $test_heterogeneous_items_prefixItemsz@TestValidationErrorMessages.test_heterogeneous_items_prefixItems   s?    "$6""' # 
 	D	
r1   c                ^    i gdd}| j                  g d|      }| j                  |d       y )NF)rC  rt  r  r   z=Unevaluated items are not allowed ('bar', 37 were unexpected)r   r   s      r   /test_heterogeneous_unevaluatedItems_prefixItemszKTestValidationErrorMessages.test_heterogeneous_unevaluatedItems_prefixItems  s?    "$5A""' # 
 	K	
r1   c                d    di idd}| j                  i ddd|      }| j                  |d       y	)
K
        Not valid deserialized JSON, but this should not blow up.
        r   F)rz  r   r[  r   r   r_   r   r   z?Additional properties are not allowed (37, 'a' were unexpected)Nr   r   s      r   2test_heterogeneous_properties_additionalPropertieszNTestValidationErrorMessages.test_heterogeneous_properties_additionalProperties  sJ     "'UK""e4 # 
 	M	
r1   c                d    di idd}| j                  i ddd|      }| j                  |d       y	)
r  r   Fry  r[  r   r  r   z@Unevaluated properties are not allowed (37, 'a' were unexpected)Nr   r   s      r   3test_heterogeneous_properties_unevaluatedPropertieszOTestValidationErrorMessages.test_heterogeneous_properties_unevaluatedProperties$  sJ     "'eL""e4 # 
 	N	
r1   N)=rW   r   rX   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r"  r%  r'  r)  r,  r0  r2  r4  r7  r<  r>  r@  rD  rH  rL  rN  rS  rX  r^  r`  rc  rf  ri  rl  ro  rq  ru  rw  r|  r  r  r  r  r  r  r  r  r   r1   r   r   r   2  s5   !??I
<EHD

DD5<9	32

+
<M>5;<G57<CH
<D

A
	





BD
J
B

&
C
	


	
	


r1   r   c                      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y)TestValidationErrorDetailsc                6   d}dddiddigi}t        j                  |      }t        |j                  |            }| j	                  t        |      d       |d   }| j	                  |j                  d       | j	                  |j                  |d          | j	                  |j                  |       | j	                  |j                  |       | j                  |j                         | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                   d	       | j	                  |j"                  t        dg             | j	                  |j$                  t        dg             | j	                  |j&                  t        dg             | j	                  t        |j(                        d
       t+        |j(                        \  }}| j	                  |j                  d       | j	                  |j                  |d   d   d          | j	                  |j                  |       | j	                  |j                  |d   d          | j-                  |j                  |       | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                   d	       | j	                  |j"                  t        ddg             | j	                  |j$                  t        ddg             | j	                  |j&                  t        g d             | j/                  |j(                         | j	                  |j                  d       | j	                  |j                  |d   d   d          | j	                  |j                  |       | j	                  |j                  |d   d          | j-                  |j                  |       | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                   d	       | j	                  |j"                  t        ddg             | j	                  |j$                  t        ddg             | j	                  |j&                  t        g d             | j	                  t        |j(                        d       y )NrG  anyOfr      r   r   rE   r   $r   )r  r   r   )r  rE   r   )r   r   r=   r>   r(   rF   r   rC   r   r   assertIsNoneparentpathr   relative_pathabsolute_path	json_pathrD   relative_schema_pathabsolute_schema_pathcontextsorted_errorsassertIsassertFalser/   r   r   r   r   ee1e2s           r   
test_anyOfz%TestValidationErrorDetails.test_anyOf6  sA   B"
 ..v6	i++H56Va(1Ig.**F7O<X.6*!((#r+%)4%)4c*wi(89//y1AB//y1ABQYY+qyy)By1++VG_Q-?	-JKh/F7OA$67bii#%),))595))595s+9~)>?00%I2GH##U+B%C	
 	$v.++VG_Q-?-GHh/F7OA$67bii#%),))595))595s+6{);<00%F2DE00%8L2MNRZZ!,r1   c                "   ddi}dddiddddgiidgi}t        j                  |      }t        |j                  |            }| j	                  t        |      d       |d	   }| j	                  |j                  d       | j	                  |j                  |d          | j	                  |j                  |       | j	                  |j                  |       | j                  |j                         | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                   d
       | j	                  |j"                  t        dg             | j	                  |j$                  t        dg             | j	                  |j&                  t        dg             | j	                  t        |j(                        d       t+        |j(                        \  }}| j	                  |j                  d       | j	                  |j                  |d   d	   d          | j	                  |j                  |       | j	                  |j                  |d   d	          | j-                  |j                  |       | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                  t        g              | j	                  |j                   d
       | j	                  |j"                  t        d	dg             | j	                  |j$                  t        d	dg             | j	                  |j&                  t        g d             | j/                  |j(                         | j	                  |j                  d       | j	                  |j                  dg       | j	                  |j                  d       | j	                  |j                  ddgi       | j-                  |j                  |       | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                   d       | j	                  |j"                  t        g d             | j	                  |j$                  t        g d             | j	                  |j&                  t        g d             | j/                  |j(                         y )Nr   rE   r   r   r   enumr   r   rz  r   r  )r   r   r   $.foo)rE   rz  r   r  )r   rE   rz  r   r  )r   r   r=   r>   r(   rF   r   rC   r   r   r  r  r  r   r  r  r  rD   r  r  r  r  r  r  r  s           r   	test_typez$TestValidationErrorDetails.test_type{  sG   1:#$#(6A3-"8
 ..v6	i++H56Va(1If-**F6N;X.6*!((#r+%)4%)4c*vh8//xA//xAQYY+qyy)Bv.++VF^A->v-FGh/F6N1$56bii#%),))595))595s+6{);<00%F2DE00%8K2LM$v.++aS1a(VaSM2bii#%.1))5%>:))5%>:w/NNE"BC	
 	##U+K%L	
 	##:;	

 	$r1   c                   ddgddd}dddid	did
g dddi}t        j                  |      }|j                  |      }t        |      \  }}}}| j	                  |j
                  t        dg             | j	                  |j
                  t        dg             | j	                  |j
                  t        dg             | j	                  |j
                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  t        dg             | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d	       | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       y )Nr   rE      spam)r   r   r[  quuxrz  r   r   r!  
   )r   rU        )r   r  rZ  r   r[  r   $.barz$.bazr  r  r   )r   r   r>   r  r(   r  r   r  r  r  r   )	r/   r   r   r   r   r  r  e3e4s	            r   test_single_nestingz.TestValidationErrorDetails.test_single_nesting  sT   aSVD)"A#%|<
 ..v6	&&x0&v.BB%.1%.1%.1%.1))5%>:))5%>:))5%>:))5%>:))5%>:))5%>:))5%>:))5%>:w/w/w/w/z2v.y1v.r1   c                    ddddgiddg}dddgddd	gid
ddiddiddddd}t        j                  |      }|j                  |      }t        |      \  }}}}}	}
| j	                  |j
                  t        g              | j	                  |j
                  t        dg             | j	                  |j
                  t        ddg             | j	                  |j
                  t        g d             | j	                  |	j
                  t        g d             | j	                  |
j
                  t        ddg             | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       | j	                  |	j                  d       | j	                  |
j                  d       | j	                  |j                  t        dg             | j	                  |j                  t        ddg             | j	                  t        |j                        g d       | j	                  t        |j                        g d       | j	                  t        |	j                        g d        | j	                  t        |
j                        g d!       | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       | j	                  |	j                  d       | j	                  |
j                  d       y )"NrE   r   r[  r  r  r   r   r  rN   r   rh  Tr!  )r   r[  r  )r   r   r   r   )rE   r   r   )rE   r   r[  r   r  $[0]z$[1].barz$[1].bar.barz$[1].bar.bazz$[1].foor   r   )r   rz  r   r   )r   rz  r   rz  r   rh  )r   rz  r   rz  r[  r!  )r   rz  r   r  )r   r   r>   r  r(   r  r   r  rD   r=   r   )r/   r   r   r   r   r  r  r  r  e5e6s              r   test_multiple_nestingz0TestValidationErrorDetails.test_multiple_nesting  s   q%!6?!8,"QF+ '$.#5$.?'	
" ..v6	&&x0!.v!6BBB%),%*-%E
"34%(9":;%(9":;%E
"34s+v.z2~6~6z2x9/@)AB "H	
 	 K	
 	 K	
 	 "H	
 	v.v.v.z2z2v.r1   c           	     l   dddddgddiddd	d
iidddgiiddgdd	d
iid}dddddddiididi}t        j                  |      }|j                  |      \  }| j                  |j                  t        dg             | j                  |j                  t        g d             | j                  |j                  d       |j                  \  }| j                  |j                  t        g d             | j                  |j                  t        g d             | j                  |j                  d       |j                  \  }| j                  |j                  t        g d             | j                  |j                  t        g d             | j                  |j                  d       y )Nnoder  r   r   childrenr   r   ^.*$r   z#/definitions/node)r   r  )r   r  )r   rh  rz  root)definitionsr   rh  rz  r_   ab)rz  r  r  z$.root)r  r  r_   )	rz  r  r  r   rz  r  r  r  r  z$.root.children.a)r  r  r_   r  r  )rz  r  r  r   rz  r  r  r  r  r   rz  r  r  r  r  z$.root.children.a.children.ab)	r   r   r>   r(   r  r   r  r  r  )r/   r   r   r   r  r  r  s          r   test_recursivez)TestValidationErrorDetails.test_recursive,  s     (%+Z$8 !'% )1$*(.0D-&6")	' * !F,@#AB1
8  #  &#%

  ..v6	""8,%/:""E*I$J	
 	h/ii))51J+KL##U
&	
 	':;jje;	

 	##U&	
* 	'FGr1   c                   ddd}ddddi}t        j                  |      }|j                  |      }t        |      \  }}| j	                  |j
                  t        dg             | j	                  |j
                  t        dg             | j	                  |j                  d	       | j	                  |j                  d
       | j	                  |j                  d       | j	                  |j                  d       y )Nr   r   r   r   r   rG  r   r   r   r  r  r   r   	r   r   r>   r  r(   r  r   r  r   r/   r   r   r   r   r  r  s          r   test_additionalPropertiesz4TestValidationErrorDetails.test_additionalProperties  s     +(9*KL..v6	&&x0v&B%.1%.1w/w/v.y1r1   c                   ddd}dddiddidi}t        j                  |      }|j                  |      }t        |      \  }}| j	                  |j
                  t        d	g             | j	                  |j
                  t        d
g             | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       | j	                  |j                  d       y )NrE   r   r   r  r   r   r   rG  r   r   r  r  r  r  s          r   test_patternPropertiesz1TestValidationErrorDetails.test_patternProperties  s    Q')!1~"
 ..v6	&&x0v&B%.1%.1w/w/v.y1r1   c                   ddg}g dddd}t        j                  |      }|j                  |      }t        |      \  }}| j	                  |j
                  t        dg             | j	                  |j
                  t        dg             | j	                  |j                  d       | j	                  |j                  d	       | j	                  |j                  d
       | j	                  |j                  d       y )Nr   rE   r   rG  r  r   r   r  $[1]r   r   r  r  s          r   test_additionalItemsz/TestValidationErrorDetails.test_additionalItems  s    1:(1a@

 ..v6	&&x0v&B%*-%*-v.v.v.y1r1   c                   g d}i gdddd}t        j                  |      }|j                  |      }t        |      \  }}| j	                  |j
                  t        dg             | j	                  |j
                  t        dg             | j	                  |j                  d       | j	                  |j                  d	       | j	                  |j                  d
       | j	                  |j                  d       y )N)r   r   rE   r   rG  r  r   rE   r   r  z$[2]r   r   r  r  s          r   test_additionalItems_with_itemsz:TestValidationErrorDetails.test_additionalItems_with_items  s    $T(1a@

 ..v6	&&x0v&B%*-%*-v.v.v.y1r1   c                   ddi}ddddiii}t        j                  |      }|j                  |      \  }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  t        g              | j                  |j                  d       | j                  |j                  t        ddg             y )Nr   r   propertyNamesr   r   z0'foo' should not be valid under {'const': 'foo'}r  
r   r   r>   r(   r   r   r  r   r  rD   )r/   r   r   r   errors        r   test_propertyNamesz-TestValidationErrorDetails.test_propertyNames  s    2;!EGU+;#<=..v6	&&x0%0MM>	
 	U2Y/#.**E?E2J,KLr1   c                   ddiddid}t        j                  |      }|j                  d      \  }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  t        g              | j                  |j                  d       | j                  |j                  t        ddg             y )Nr   r      )ifthen13 was expectedr  r  r  r/   r   r   r  s       r   test_if_thenz'TestValidationErrorDetails.test_if_then      B-bM

 ..v6	&&r*'2(9:U2Y/#.**E672C,DEr1   c                   ddiddid}t        j                  |      }|j                  d      \  }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  t        g              | j                  |j                  d       | j                  |j                  t        ddg             y )	Nr   r   r  )r  elser  r  r  r  r  r  s       r   test_if_elsez'TestValidationErrorDetails.test_if_else  r  r1   c                2   t        j                  d      }|j                  d      \  }| j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  fdd d ddt        g       df       y )NFr   zFalse schema does not allow 12r  )r   r   r>   r(   r   r   rC   r   r   rD   r  r   )r/   r   r  s      r   test_boolean_schema_Falsez4TestValidationErrorDetails.test_boolean_schema_False  s    ..u5	&&r*%%!! 1b		
r1   c                   ddddii}}t        j                  d|it        j                  di ||i            }|j                  d	d
i      \  }| j	                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  fdddd
t        d	g      ddit        ddg      df       y )NsomeRefr   r   r   r   rp   storeresolverr   notAnIntegerz''notAnInteger' is not of type 'integer'r  )r   r   _RefResolverr>   r(   r   r   rC   r   r  r   rD   r  r   )r/   refr   r   r  s        r   test_refz#TestValidationErrorDetails.test_ref'  s    "869:M!NV..SM,,RC=I
	 &&~'>?%%##!!	 :ug#-v67		
r1   c                   dddii i ddigi}t        j                  |      }|j                  g d      \  }}| j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  fddddt        d	g      ddit        g d
      df       | j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  fddddt        dg      ddit        g d      df       y )NrC  r   r   r   rN   rF  r   rE   r   )rC  r   r   r  z"5 is greater than the maximum of 3rG  )rC  rN   r   $[3]r   r   r>   r(   r   r   rC   r   r  r   rD   r  r   )r/   r   r   
type_error	min_errors        r   test_prefixItemsz+TestValidationErrorDetails.test_prefixItemsF  s[   68"4b"y!n!MN33F;	 ) 5 56F G
I""$$**##((!!&&$$	 ,qc
"01		
, 	!!##))""''  %%##	 5qc
A34		
r1   c                   ddii gd}t        j                  |      }|j                  g d      \  }}| j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  fddddt        dg      ddit        ddg      d	f       | j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  fd
dddt        dg      ddit        ddg      df       y )Nr   r   rB  )r   r   r   rU  r[  z2 is not of type 'string'r   rE   r   r  z4 is not of type 'string'rU  rN   r  r  r/   r   r   r  r  s        r   rD  z6TestValidationErrorDetails.test_prefixItems_with_itemsw  sE   h'4
 33F;	&&'BCB

""  			 ,qc
"w'(		
, 	

""  			 ,qc
"w'(		
r1   c                ~   ddidd}t        j                  |      }|j                  g d      \  }| j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  fdddg dt        g       ddiddt        dg      d	f       y
)z
        `contains` + `maxContains` produces only one error, even if there are
        many more incorrectly matching elements.
        r   r   r   r\  )r   r   r   rU  r[  r  r]  rW  r  r  Nr  r  s       r   r^  z1TestValidationErrorDetails.test_contains_too_many  s    
  &x0C33F;	&&'JK%%##!!	 M3b	$h/Bzl#		
r1   c                ~   ddidd}t        j                  |      }|j                  g d      \  }| j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  fdddg dt        g       ddiddt        dg      d	f       y )
Nr   r   r   rP  )r   r   rU  rR  rQ  r  r  r  r  s       r   rS  z0TestValidationErrorDetails.test_contains_too_few  s    %x0C33F;	&&}5%%##!!	? b	$h/Bzl#	
r1   c                   ddidd}t        j                  |      }|j                  ddg      \  }| j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  fddddiddgt        g       ddiddt        dg      df       y )	Nr   r   r   rP  rU  z7[2, 4] does not contain items matching the given schemar  r  r  r  s       r   test_contains_nonez-TestValidationErrorDetails.test_contains_none  s    %x0C33F;	&&1v.%%##!!	 J"Ab	$h/Bzl#		
r1   c                   dddgiidddgdid}t        j                  |      }|j                  di i      \  }}| j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  f	d	ddgi t        dg      ddgit        g d
      t        g d
      df	       | j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  f	dddgi t        dg      ddgdt        g d
      t        g d
      df	       y )Nr   rh  r   apropz#/$defs/foor[  )r   rh  )r   rz  z'bar' is a required property)rz  r  rh  z$.apropz'baz' is a required property)r   r   r>   r(   r   r   rC   r   r  r   rD   r  r  r   r  s        r   test_ref_siblingz+TestValidationErrorDetails.test_ref_sibling  s   j5'23)!&
 33F;	&&}5B

""  		''
 /wi eW%9:9:
	
0 	

""  		''
 /wi &UG<9:9:
	
r1   N)rW   r   rX   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rD  r^  rS  r  r  r   r1   r   r  r  3  st    C-JK%Z%/N;/zcHJ2"2,2(2(M FF
2
>/
b2
h
>
<
6<
r1   r  c                  0    e Zd Zd Zd Zd Zd Zd Zd Zy)MetaSchemaTestsMixinc                    | j                  t        j                        5  | j                  j	                  ddi       d d d        y # 1 sw Y   y xY w)Nrz  r   r   r   r   r-   r   r.   s    r   test_invalid_propertiesz,MetaSchemaTestsMixin.test_invalid_propertiesD  s9    z556NN''r(:; 766   AAc                    | j                  t        j                        5  | j                  j	                  ddi       d d d        y # 1 sw Y   y xY w)Nr!  1r  r.   s    r   test_minItems_invalid_stringz1MetaSchemaTestsMixin.test_minItems_invalid_stringH  s9    z556NN''S(9: 766r  c                :   | j                   t        j                  t        j                  hv rF| j	                  t
        j                        5  | j                   j                  dg i       ddd       y| j                   j                  dg i       y# 1 sw Y   yxY w)z
        Technically, all the spec says is they SHOULD have elements, not MUST.

        (As of Draft 6. Previous drafts do say MUST).

        See #529.
        r  Nr-   r   r   r   r   r   r   r   r.   s    r   test_enum_allows_empty_arraysz2MetaSchemaTestsMixin.test_enum_allows_empty_arraysM  s|     >>&&&&
 
 "":#9#9:++VRL9 ;: NN''5 ;:s   BBc                B   | j                   t        j                  t        j                  hv rH| j	                  t
        j                        5  | j                   j                  dddgi       ddd       y| j                   j                  dddgi       y# 1 sw Y   yxY w)z
        Technically, all the spec says is they SHOULD be unique, not MUST.

        (As of Draft 6. Previous drafts do say MUST).

        See #529.
        r  r   Nr  r.   s    r   !test_enum_allows_non_unique_itemsz6MetaSchemaTestsMixin.test_enum_allows_non_unique_items^  s     >>&&&&
 
 "":#9#9:++Vb"X,>? ;: NN''"b(:; ;:s    BBc                    | j                  t        j                        5  | j                  j	                  ddi       d d d        y # 1 sw Y   y xY w)NrK  
*notaregexr  r.   s    r   test_schema_with_invalid_regexz3MetaSchemaTestsMixin.test_schema_with_invalid_regexo  s9    z556NN''L(AB 766r  c                B    | j                   j                  ddid        y )NrK  r  r  )r-   r   r.   s    r   >test_schema_with_invalid_regex_with_disabled_format_validationzSMetaSchemaTestsMixin.test_schema_with_invalid_regex_with_disabled_format_validations  s$    ##% 	$ 	
r1   N)	rW   r   rX   r  r  r	  r  r  r  r   r1   r   r  r  B  s!    <;
6"<"C
r1   r  c                  ~    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y)ValidatorTestMixinc                b    | j                  | j                  i       t        j                         y r3   )assertIsInstancer-   r   r.   s    r   )test_it_implements_the_validator_protocolz<ValidatorTestMixin.test_it_implements_the_validator_protocol{  s!    dnnR0)2E2EFr1   c                    | j                   \  }}| j                  | j                  |      j                  |             y r3   )validr   r-   r   r/   r   r   s      r   test_valid_instances_are_validz1ValidatorTestMixin.test_valid_instances_are_valid~  s0    ::v.77ABr1   c                    | j                   \  }}| j                  | j                  |      j                  |             y r3   )invalidr  r-   r   r  s      r   $test_invalid_instances_are_not_validz7ValidatorTestMixin.test_invalid_instances_are_not_valid  s2    <</88BCr1   c                z    | j                  t               t               i      j                  t                      y )N)r   )r-   r   r   r.   s    r   (test_non_existent_properties_are_ignoredz;ValidatorTestMixin.test_non_existent_properties_are_ignored  s'    &(+,55vx5Hr1   c                H   ddit               }}| j                  ||      }|j                  ddi| j                  j                        }| j                  ddi| j                  j                  |j                        }| j                  ||       | j                  ||       y )Nr   r   r  r   )r   r  )r  	_resolver)r   r-   evolveFORMAT_CHECKERr!  r(   assertNotEqual)r/   r   r  rj   r   expecteds         r   test_evolvezValidatorTestMixin.test_evolve  s    "()!4mo>>) " 
 ooH%>>88  

 >>X>>88mm " 
 	h'C*r1   c                   | j                  t              5  t         G d d| j                               }ddd        i d      }| j	                  |j
                  g d       |j                  ddi	      }| j	                  |j
                  g d       | j	                  |j                  d       y# 1 sw Y   xY w)
ar  
        Subclassing validators isn't supported public API, but some users have
        done it, because we don't actually error entirely when it's done :/

        We need to deprecate doing so first to help as many of these users
        ensure they can move to supported APIs, but this test ensures that in
        the interim, we haven't broken those users.
        c                  2    e Zd Z ed       Z ed      Zy):ValidatorTestMixin.test_evolve_with_subclass.<locals>.OhNoc                 
    g dS )Nr   r   r   r1   r   ru   zCValidatorTestMixin.test_evolve_with_subclass.<locals>.OhNo.<lambda>  s    Ir1   )factoryr   defaultN)rW   r   rX   r   r   _barr   r1   r   OhNor)    s    $56R(r1   r/  Nr   )r   r   r   r   r   )assertWarnsDeprecationWarningr   r-   r(   r   r"  r.  )r/   r/  r   r   s       r   test_evolve_with_subclassz,ValidatorTestMixin.test_evolve_with_subclass  s     01)t~~ ) ) 2 $		2vy&9:),2& 21s   B44B=c                d    | j                  | j                  i       j                  dd             y )Nr   r   )r   r-   r   r.   s    r   #test_is_type_is_true_for_valid_typez6ValidatorTestMixin.test_is_type_is_true_for_valid_type  s$    r*225(CDr1   c                d    | j                  | j                  i       j                  dd             y )Nr   r   r  r-   r   r.   s    r   &test_is_type_is_false_for_invalid_typez9ValidatorTestMixin.test_is_type_is_false_for_invalid_type  s&    +33E7CDr1   c                    | j                  | j                  i       j                  dd             | j                  | j                  i       j                  dd             y )NTr   r   r7  r.   s    r   ,test_is_type_evades_bool_inheriting_from_intz?ValidatorTestMixin.test_is_type_evades_bool_inheriting_from_int  sJ    +33D)DE+33D(CDr1   c                   dddii}t        j                  | j                  | j                  j                  j	                  dd             } ||      }|j                  ddt        d      t        d      z  g       d	i g d
d g}| j                  |j                  |      D cg c]  }|j                   c}|       y c c}w )Nr   r   r   c                ^    t        |t        t        t        f      xr t        |t               S r3   )
isinstanceintfloatr   boolr  r	  s     r   ru   zGValidatorTestMixin.test_it_can_validate_with_decimals.<locals>.<lambda>  s,    zC0( (2$UD11(2r1   r&   rE   g?r  r   T)
r   r   r-   r6   redefiner   r   r(   r>   r   )r/   r   r-   r   r  r  s         r   "test_it_can_validate_with_decimalsz5ValidatorTestMixin.test_it_can_validate_with_decimals  s    FH-.%%NN44==2
	 f%	AsGAJ$;<="b$-)2)>)>w)GH)GU^^)GH	
Hs   #B?c                `    | j                  ddit                     }|j                  d       y )Nr  carrotr  bugs)r-   r   r   r/   r   s     r   7test_it_returns_true_for_formats_it_does_not_know_aboutzJValidatorTestMixin.test_it_returns_true_for_formats_it_does_not_know_about  s1    NNx  # 
	 	6"r1   c                \    | j                  i       }| j                  |j                         y r3   )r-   r  r  rH  s     r   ,test_it_does_not_validate_formats_by_defaultz?ValidatorTestMixin.test_it_does_not_validate_formats_by_default  s$    NN2&	)223r1   c                    t               }t        d      |j                  dt               fd       } j                  ddi|      }|j	                  d        j                  t        j                        5 }|j	                  d       d d d         j                  j                  j                         y # 1 sw Y   0xY w)	NzBad!r   )raisesc                J    | dk(  ry| dk(  rj                  d|  d       y )NgoodTbadzWhat is z? [Baby Don't Hurt Me])r    )r  rP  r/   s    r   checkzTValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provided.<locals>.check  s/    %			HUG+ABCr1   r  r  rO  rP  )r   
ValueErrorr  r-   r   r   r   r   r  	exceptioncause)r/   r  rQ  r   cmrP  s   `    @r   2test_it_validates_formats_if_a_checker_is_providedzEValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provided  s    / 	j	1	D 
2	D NNug # 
	 	6"z99:bu% ; 	bll((#.	 ;:s   =B>>Cc                    t               }d|gi}t        j                  | j                  | j                  j                  j                  |d             } ||      j                  d       y )Nr   c                "    t        |t              S r3   r=  r>  rA  s     r   ru   z@ValidatorTestMixin.test_non_string_custom_type.<locals>.<lambda>  s    z%'=r1   rB  r  )r   r   r   r-   r6   rC  r   )r/   non_string_typer   Crazys       r   test_non_string_custom_typez.ValidatorTestMixin.test_non_string_custom_type  s_     (?+,!!NN44===
 	fr"r1   c                t   t        j                  | j                  | j                  j                  j	                  dd             }| j                  t        j                        5 } |ddi      j                  d       ddd       | j                  dt        j                               y# 1 sw Y   /xY w)	zh
        A tuple instance properly formats validation errors for uniqueItems.

        See #224
        r   c                "    t        |t              S r3   )r=  tuplerA  s     r   ru   zNValidatorTestMixin.test_it_properly_formats_tuples_in_errors.<locals>.<lambda>  s    z%'?r1   rB  uniqueItemsT)rE   rE   Nz(1, 1) has non-unique elements)r   r   r-   r6   rC  r   r   r   r   rz   strrS  )r/   TupleValidatorr  s      r   )test_it_properly_formats_tuples_in_errorsz<ValidatorTestMixin.test_it_properly_formats_tuples_in_errors  s     $**NN44==?
 z99:aM401::6B ;6AKK8HI ;:s   &B..B7c                   ddd}t        dd      t        j                  | j                  | j                  j                  j                  d fdd      	      } ||      }t        g d
      t        dgdgg      t        dg      t        dg      gt        dg      gt        dg      ggt        dg      ggggt        dg      gggggt        t        dg      g      t        t        dg      g      g dd       dd      g dt        dg      g       dt        dg      g      g d dt        dg            g       d dt        dg            g      gt        t        t        dg                  t        t        t        dg                  gg
}|D ]  }|j                  |        t        g d      t        dgdgg      t        dg      t        dg      gt        dg      gt        dg      ggt        dg      ggggt        dg      gggggt        t        dg      g      t        t        dg      g      g dd       dd      g dt        dg      g       dt        dg      g      g d dt        dg            g       d dt        dg            g      gt        t        t        dg                  t        t        t        dg                  gg
}|D ];  }| j                  t        j                        5  |j                  |       ddd       = y# 1 sw Y   HxY w)zO
        Allow array to validate against another defined sequence type
        r   T)r   r`  	MyMappingza, bc                .    t        |t        t        f      S r3   )r=  r=   r   rA  s     r   ru   zBValidatorTestMixin.test_check_redefined_sequence.<locals>.<lambda>  s    Je}5r1   c                (    t        |t        f      S r3   )r=  r*   )r  r	  re  s     r   ru   zBValidatorTestMixin.test_check_redefined_sequence.<locals>.<lambda>  s    Zi06r1   )r   r   rB  )r_   Nr  rp   TFr   r_   )r_   r9  r_   N)r   r   r   r-   r6   redefine_manyr   r   r   r   r   )r/   r   r-   r   valid_instancesr   invalid_instancesre  s          @r   test_check_redefined_sequencez0ValidatorTestMixin.test_check_redefined_sequence  sD    "$7{F3	%%NN44BB		
	 f%	 ,-E7QC.!E7^UA3Z(UGnqc
|,w !"#s~&6%78E5'N#$eUA3ZL&9:sA	#u 56#qc
|,#ug/0
 #	#uaSz :;<#	#ueW~ >?@ 5w()5uaSz1B+CD!
& (Hx( ( /"E7UG$%E7^UE7^,UGnug/0w !"#w(8'9&:%;<E5'N#$eUE7^,<&=>sE"Ic5$9:#ug/0#ug/0
 #	#ueW~ >?@#	#ueW~ >?@ 5w()5ueW~1F+GH!
& *H"":#=#=>""8, ?> *>>s   L;;M	c                    | j                  t              5  | j                  i       j                  }d d d        | j	                  t
        j                         y # 1 sw Y   *xY wr3   )r1  r2  r-   r  r  r   r  )r/   r  s     r   .test_it_creates_a_ref_resolver_if_not_providedzAValidatorTestMixin.test_it_creates_a_ref_resolver_if_not_providedT  sI    01~~b)22H 2h
(?(?@ 21s   AA$c                    dddi}}t        j                  di ||i      }| j                  d|i|      }| j                  t        j
                        5  |j                  d        d d d        y # 1 sw Y   y xY w)NsomeCoolRefr   r   rp   r  r   r  )r   r  r-   r   r   r   r   r/   r  r   r  r   s        r   /test_it_upconverts_from_deprecated_RefResolverszBValidatorTestMixin.test_it_upconverts_from_deprecated_RefResolversY  sl    #fi%8V**2r#vGNNFC=8ND	z99:t$ ;::s   A00A9c                      G  fdd      } |       }ddi} j                  t        j                        5   j                  ||      j	                  d       ddd       y# 1 sw Y   yxY w)zb
        Legacy RefResolvers support only the context manager form of
        resolution.
        c                  "    e Zd Ze fd       Zy)nValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolvers.<locals>.LegacyRefResolverc              3  >   K   j                  |d       ddi y w)Nthe refr   r   r(   )thisr  r/   s     r   	resolvingzxValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolvers.<locals>.LegacyRefResolver.resolvingh  s"       i0y))s   N)rW   r   rX   r   ry  r.   s   r   LegacyRefResolverrt  g  s    * *r1   rz  r   rv  r  N)r   r   r   r-   r   )r/   rz  r  r   s   `   r   @test_it_upconverts_from_yet_older_deprecated_legacy_RefResolverszSValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolversa  s\    	* 	* %&)$z99:NN6HN5>>tD ;::s   #A$$A-N)rW   r   rX   r  r  r  r  r&  r3  r5  r8  r:  rD  rI  rK  rV  r\  rc  rk  rm  rq  r{  r   r1   r   r  r  z  sm    GCDI+('.EEE
*#4/0
#J"@-DA
%Er1   r  c                  (    e Zd ZdZd Zd Zd Zd Zy)AntiDraft6LeakMixinzN
    Make sure functionality from draft 6 doesn't leak backwards in time.
    c                    | j                  t        j                        5 }| j                  j	                  d       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)NTzTrue is not of typer   r   r   r-   r   rz   ra  rS  r/   r  s     r   test_True_is_not_a_schemaz-AntiDraft6LeakMixin.test_True_is_not_a_schemay  sP    z556!NN''- 7+S-=> 76   A**A3c                    | j                  t        j                        5 }| j                  j	                  d       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)NFzFalse is not of typer  r  s     r   test_False_is_not_a_schemaz.AntiDraft6LeakMixin.test_False_is_not_a_schema~  sP    z556!NN''. 7,c!++.>? 76r  c                    | j                  t              5 }| j                  d      j                  d       d d d        | j	                  j
                  t        j                         y # 1 sw Y   4xY w)NTr   r   	Exceptionr-   r   assertNotIsInstancerS  r   r   r  s     r   5test_True_is_not_a_schema_even_if_you_forget_to_checkzIAntiDraft6LeakMixin.test_True_is_not_a_schema_even_if_you_forget_to_check  sQ    y)QNN4 ))"- *  j.H.HI *)   !A**A3c                    | j                  t              5 }| j                  d      j                  d       d d d        | j	                  j
                  t        j                         y # 1 sw Y   4xY w)NFr   r  r  s     r   6test_False_is_not_a_schema_even_if_you_forget_to_checkzJAntiDraft6LeakMixin.test_False_is_not_a_schema_even_if_you_forget_to_check  sQ    y)QNN5!**2. *  j.H.HI *)r  N)rW   r   rX   __doc__r  r  r  r  r   r1   r   r}  r}  t  s    ?
@
J
Jr1   r}  c                  \    e Zd ZU ej                  Zi i fZded<   ddidfZd Z	d Z
d Zd	 Zy
)TestDraft3Validatortuple[dict, dict]r  r   r   r   c                \    | j                  ddi      }|j                  t                      y Nr   any)r-   r   r   rH  s     r   #test_any_type_is_valid_for_type_anyz7TestDraft3Validator.test_any_type_is_valid_for_type_any  s$    NNFE?3	68$r1   c                P   t        j                  | j                  | j                  j                  j	                  dd             } |ddi      }|j                  d       | j                  t        j                        5  |j                  d       ddd       y# 1 sw Y   yxY w)z(
        Sigh, because why not.
        r  c                "    t        |t              S r3   rY  rA  s     r   ru   zBTestDraft3Validator.test_any_type_is_redefinable.<locals>.<lambda>  s    j.Dr1   rB  r   r   r   N)	r   r   r-   r6   rC  r   r   r   r   )r/   r[  r   s      r   test_any_type_is_redefinablez0TestDraft3Validator.test_any_type_is_redefinable  s     !!NN44==D
 65/*	2z99:u% ;::s   BB%c                v    | j                  | j                  ddi      j                  t                            y r  )r   r-   r   r   r.   s    r   !test_is_type_is_true_for_any_typez5TestDraft3Validator.test_is_type_is_true_for_any_type  s(    7@@JKr1   c                    | j                  | j                  i       j                  dd             | j                  | j                  ddi      j                  d             y )NTr   r   r  )r   r-   r   r   r.   s    r   6test_is_type_does_not_evade_bool_if_it_is_being_testedzJTestDraft3Validator.test_is_type_does_not_evade_bool_if_it_is_being_tested  sH    r*224CD7@@FGr1   N)rW   r   rX   r   r   r-   r  __annotations__r  r  r  r  r  r   r1   r   r  r    sA    **I "BxE'y!5(G%&LHr1   r  c                  D    e Zd ZU ej                  Zi i fZded<   ddidfZy)TestDraft4Validatorr  r  r   r   r   N)	rW   r   rX   r   r   r-   r  r  r  r   r1   r   r  r    +    **I "BxE'y!5(Gr1   r  c                  D    e Zd ZU ej                  Zi i fZded<   ddidfZy)TestDraft6Validatorr  r  r   r   r   N)	rW   r   rX   r   r  r-   r  r  r  r   r1   r   r  r    r  r1   r  c                  D    e Zd ZU ej                  Zi i fZded<   ddidfZy)TestDraft7Validatorr  r  r   r   r   N)	rW   r   rX   r   r   r-   r  r  r  r   r1   r   r  r    r  r1   r  c                  D    e Zd ZU ej                  Zi i fZded<   ddidfZy)TestDraft201909Validatorr  r  r   r   r   N)	rW   r   rX   r   Draft201909Validatorr-   r  r  r  r   r1   r   r  r    +    //I "BxE'y!5(Gr1   r  c                  D    e Zd ZU ej                  Zi i fZded<   ddidfZy)TestDraft202012Validatorr  r  r   r   r   N)	rW   r   rX   r   r   r-   r  r  r  r   r1   r   r  r    r  r1   r  c                      e Zd ZdZd Zy)TestLatestValidatorzQ
    These really apply to multiple versions but are easiest to test on one.
    c                    d}d|i}t        j                  di |di      }t        j                  ||      }| j                  t        j
                        5  |j                  d        d d d        y # 1 sw Y   y xY w)Nro  r   rp   Fr  r  )r   r  r   r   r   r   r   rp  s        r   2test_ref_resolvers_may_have_boolean_schemas_storedzFTestLatestValidator.test_ref_resolvers_may_have_boolean_schemas_stored  sh    #**2r#uF..vI	z99:t$ ;::s   A22A;N)rW   r   rX   r  r  r   r1   r   r  r    s    %r1   r  c                  f    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y)TestValidatorForc                    ddi}| j                  t        j                  |      t        j                         ddi}| j                  t        j                  |      t        j                         y )Nr   &http://json-schema.org/draft-03/schema'http://json-schema.org/draft-03/schema#)r  r   validator_forr   r9   s     r   test_draft_3zTestValidatorFor.test_draft_3  `    EF$$V,&&	

 FG$$V,&&	
r1   c                    ddi}| j                  t        j                  |      t        j                         ddi}| j                  t        j                  |      t        j                         y )Nr   &http://json-schema.org/draft-04/schema'http://json-schema.org/draft-04/schema#)r  r   r  r   r9   s     r   test_draft_4zTestValidatorFor.test_draft_4  r  r1   c                    ddi}| j                  t        j                  |      t        j                         ddi}| j                  t        j                  |      t        j                         y )Nr   &http://json-schema.org/draft-06/schema'http://json-schema.org/draft-06/schema#)r  r   r  r  r9   s     r   test_draft_6zTestValidatorFor.test_draft_6  r  r1   c                    ddi}| j                  t        j                  |      t        j                         ddi}| j                  t        j                  |      t        j                         y )Nr   &http://json-schema.org/draft-07/schema'http://json-schema.org/draft-07/schema#)r  r   r  r   r9   s     r   test_draft_7zTestValidatorFor.test_draft_7  r  r1   c                    ddi}| j                  t        j                  |      t        j                         ddi}| j                  t        j                  |      t        j                         y )Nr   z,https://json-schema.org/draft/2019-09/schemaz-https://json-schema.org/draft/2019-09/schema#)r  r   r  r  r9   s     r   test_draft_201909z"TestValidatorFor.test_draft_201909  `    KL$$V,++	

 LM$$V,++	
r1   c                    ddi}| j                  t        j                  |      t        j                         ddi}| j                  t        j                  |      t        j                         y )Nr   ,https://json-schema.org/draft/2020-12/schema-https://json-schema.org/draft/2020-12/schema#)r  r   r  r   r9   s     r   test_draft_202012z"TestValidatorFor.test_draft_202012  r  r1   c                j    | j                  t        j                  d      t        j                         y )NTr  r   r  r   r.   s    r   	test_TruezTestValidatorFor.test_True*  s%    $$T*&&	
r1   c                j    | j                  t        j                  d      t        j                         y r  r  r.   s    r   
test_FalsezTestValidatorFor.test_False0  s%    $$U+&&	
r1   c                    t        j                  ddidd       }ddi}| j                  t        j                  |      |       y )Nri   rm   12c                &    | j                  dd      S ro   rq   rs   s    r   ru   z8TestValidatorFor.test_custom_validator.<locals>.<lambda>:  rv   r1   rw   r   r   r,   r  r  r/   r-   r   s      r   test_custom_validatorz&TestValidatorFor.test_custom_validator6  sK    %%/0+
	
 -.$$V,	
r1   c                    t        j                  ddid      }ddi}| j                  t        j                  |      |       y )Nr$   r   13rS   r   r  r  s      r   test_custom_validator_draft6z-TestValidatorFor.test_custom_validator_draft6B  sH    %% 12
	 ./$$V,	
r1   c                j    | j                  t        j                  i       t        j                         y r3   r  r.   s    r   %test_validator_for_jsonschema_defaultz6TestValidatorFor.test_validator_for_jsonschema_defaultM  s!    j..r2J4N4NOr1   c                R    | j                  t        j                  i d       d        y )Nr,  )r  r   r  r.   s    r   !test_validator_for_custom_defaultz2TestValidatorFor.test_validator_for_custom_defaultP  s    j..r4@$Gr1   c                   | j                  t              5 }t        j                  ddi       d d d        | j	                  j
                  t               | j	                  t        |j                        d       y # 1 sw Y   OxY w)Nr   unknownSchemar0  zThe metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.)	r1  r2  r   r  r(   filename__file__ra  warning)r/   rU  s     r   1test_warns_if_meta_schema_specified_was_not_foundzBTestValidatorFor.test_warns_if_meta_schema_specified_was_not_foundS  sh    01R$$Y,HI 2 	h/

O&	
	 21s   A==Bc                    t        j                  d      5 }t        j                  d       t        j                  i i        d d d        | j                         y # 1 sw Y   xY w)NTrecordalways)r   r-  )warningscatch_warningssimplefilterr   r  r  )r/   ws     r   0test_does_not_warn_if_meta_schema_is_unspecifiedzATestValidatorFor.test_does_not_warn_if_meta_schema_is_unspecified_  sN    $$D1Q!!(+$$B; 2 	 21s   -AA'c                l    ddit               }}| j                  t        j                  ||      |       y )Nr   zmailto:foo@example.com)r   r  r   r  )r/   r   r-  s      r   -test_validator_for_custom_default_with_schemaz>TestValidatorFor.test_validator_for_custom_default_with_schemae  s.    $&>?j..vw?Ir1   N)rW   r   rX   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r1   r   r  r    sP    









	
PH

Jr1   r  c                  H    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)TestValidatec                    g }t         j                  j                  |d|j                        5  t	        j
                  i |       d d d        | j                  ||g       y # 1 sw Y   xY w)Nr   )r   patchr   appendr   r   r(   )r/   r   r-   results       r   
assertUseszTestValidate.assertUsesk  sS    ZZy.&--HF+ I&* IHs   A!!A*c                    | j                  ddit        j                         | j                  ddit        j                         y )Nr   r  r   r-   r  )r  r   r   r.   s    r   test_draft3_validator_is_chosenz,TestValidate.test_draft3_validator_is_chosenq  J    HI 00 	 	

 	GH 00 	 	
r1   c                    | j                  ddit        j                         | j                  ddit        j                         y )Nr   r  r  r  )r  r   r   r.   s    r   test_draft4_validator_is_chosenz,TestValidate.test_draft4_validator_is_chosen|  r  r1   c                    | j                  ddit        j                         | j                  ddit        j                         y )Nr   r  r  r  )r  r   r  r.   s    r   test_draft6_validator_is_chosenz,TestValidate.test_draft6_validator_is_chosen  r  r1   c                    | j                  ddit        j                         | j                  ddit        j                         y )Nr   r  r  r  )r  r   r   r.   s    r   test_draft7_validator_is_chosenz,TestValidate.test_draft7_validator_is_chosen  r  r1   c                    | j                  ddit        j                         | j                  ddit        j                         y )Nr   r  r  r  r  r   r   r.   s    r   $test_draft202012_validator_is_chosenz1TestValidate.test_draft202012_validator_is_chosen  sR    J !55	 	 	
 	I !55	 	 	
r1   c                F    | j                  i t        j                         y )Nr  r  r.   s    r   )test_draft202012_validator_is_the_defaultz6TestValidate.test_draft202012_validator_is_the_default  s    rZ-L-LMr1   c                    | j                  t        j                        5 }t        j                  dddi       d d d        | j                  t        j                        d       y # 1 sw Y   /xY w)Nr   r   r   z1(?s)Failed validating '.*' in schema.*On instance)r   r   r   r   r   assertRegexra  rS  r  s     r   test_validation_error_messagez*TestValidate.test_validation_error_message  sX    z99:aVX$67 ;?	
 ;:   A''A0c                    | j                  t        j                        5 }t        j                  dddi       d d d        | j                  t        j                        d       y # 1 sw Y   /xY w)Nr   r   z3(?s)Failed validating '.*' in metaschema.*On schema)r   r   r   r   r   r  ra  rS  r  s     r   test_schema_error_messagez&TestValidate.test_schema_error_message  sW    z556!VRL1 7A	
 76r  c                    ddddddigi}| j                  t        j                        5 }t        j                  d|       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)	Nrn  r   r  r  r   r   r   z!12 is less than the minimum of 20)r   r   r   r   r   rz   ra  rS  )r/   r   r  s      r   test_it_uses_best_matchz$TestValidate.test_it_uses_best_match  so    !b1!
 z99:aF+ ;93q{{;KL ;:s   A00A9N)rW   r   rX   r  r  r  r  r  r  r  r  r  r	  r   r1   r   r  r  j  s6    +	
	
	
	

N

	Mr1   r  c                      e Zd ZdZd Zy)TestThreadinga  
    Threading-related functionality tests.

    jsonschema doesn't promise thread safety, and its validation behavior
    across multiple threads may change at any time, but that means it isn't
    safe to share *validators* across threads, not that anytime one has
    multiple threads that jsonschema won't work (it certainly is intended to).

    These tests ensure that this minimal level of functionality continues to
    work.
    c                    g fd} |        ddl m}  ||      }|j                          |j                          | j	                  |j                         fdg f       y )Nc                     	 t        j                  dd       y #   j                  t        j                                Y y xY w)Nr   Tr   )r   r   r  sysexc_info)faileds   r   r   zFTestThreading.test_validation_across_a_second_thread.<locals>.validate  s1    .##R=.clln-s	    %Ar   )Thread)targetF)	threadingr  startjoinr(   is_alive)r/   r   r  threadr  s       @r   &test_validation_across_a_second_threadz4TestThreading.test_validation_across_a_second_thread  sS    	. 	
$x(&//+V4ubkBr1   N)rW   r   rX   r  r  r   r1   r   r  r    s    
Cr1   r  c                      e Zd Zd Zd Zy)TestReferencingc                    d }t        j                  |      }ddi}t        j                  ||      }| j	                  |j                  d      |j                  d      fd       y )	Nc                0    t        j                  ddi      S )Nr   r   )r   create_resource)uris    r   retrievez=TestReferencing.test_registry_with_retrieve.<locals>.retrieve  s    ..	/BCCr1   )r  r   https://example.com/registryr   r   )TF)referencingRegistryr   r   r(   r   )r/   r  r"  r   r   s        r   test_registry_with_retrievez+TestReferencing.test_registry_with_retrieve  sf    	D '':0133FXN	#Y%7%7%>?	
r1   c                   t        j                         }ddi}t        j                  ||      }t	        j
                  d      5 }t	        j                  d       | j                  t         j                  j                        5  |j                  d       d d d        d d d        | j                         y # 1 sw Y   #xY w# 1 sw Y   'xY w)Nr   r   r!  Tr  r  r   )r#  r$  r   r   r  r  r  r   r   Unresolvabler   r  )r/   r"  r   r   r  s        r   ;test_custom_registries_do_not_autoretrieve_remote_resourceszKTestReferencing.test_custom_registries_do_not_autoretrieve_remote_resources  s    '')0133FXN	$$D1Q!!(+"";#9#9#F#FG""2& H 2 	 HG 21s$   ?CB9C9C	>CCN)rW   r   rX   r%  r(  r   r1   r   r  r    s    
	r1   r  c                      e Zd ZdZdZddi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y)TestRefResolverrp   zfoo://storedstoredr   c                    i | _         | j                  | j                  i| _        t	        j
                  | j                  | j                   | j                        | _        y r3   )referrer
stored_uristored_schemar  r   r  base_urir  r.   s    r   r0   zTestRefResolver.setUp
	  sD    oot'9'9:
"//MM4==$**
r1   c                   t         j                  j                  d   }t        j                  j                  | j                  d      5 }| j                  j                  |      5 }	 d d d        d d d        | j                  t         j                  j                         | j                  j                         y # 1 sw Y   WxY w# 1 sw Y   [xY w)Nri   resolve_remote)r   r   r5   r   r  r   r  ry  r(   r  called)r/   r  patchedresolveds       r   6test_it_does_not_retrieve_schema_urls_from_the_networkzFTestRefResolver.test_it_does_not_retrieve_schema_urls_from_the_network	  s    ((44T:ZZt}}.>?7((- . @ 	:#=#=#I#IJ( .- @?s$   C$B<&C<C	CCc                    d}dt               i| j                  d<   | j                  j                  |      5 }| j	                  || j                  d   d          d d d        y # 1 sw Y   y xY w)Nz#/properties/foor   rz  )r   r-  r  ry  r(   )r/   r  r5  s      r   test_it_resolves_local_refsz+TestRefResolver.test_it_resolves_local_refs	  sZ     ',fh&7l#]]$$S)XXt}}\'B5'IJ *))s   #A##A,c                B   dddid}t         j                  j                  |d       }|j                  d      5 }| j	                  ||d          d d d        |j                  d	      5 }| j	                  ||d          d d d        y # 1 sw Y   9xY w# 1 sw Y   y xY w)
Nzhttp://bar/schema#r   r   )ri   r_   c                &    | j                  dd      S ro   rq   r0  s    r   ru   zETestRefResolver.test_it_resolves_local_refs_with_id.<locals>.<lambda>#	      D"!5r1   rx   z#/ar_   zhttp://bar/schema#/a)r   r  from_schemary  r(   r/   r   r  r5  s       r   #test_it_resolves_local_refs_with_idz3TestRefResolver.test_it_resolves_local_refs_with_id	  s    ,E5>B**665 7 
 &(Xvc{3 ' 678Xvc{3 87 '&77s   B	*B	BBc                j   | j                   j                  | j                        5 }| j                  || j                         d d d        ddi| j                   j
                  d<   | j                   j                  d      5 }| j                  |d       d d d        y # 1 sw Y   [xY w# 1 sw Y   y xY w)Nr   r   
cached_refzcached_ref#/foo)r  ry  r.  r  r/  r  r(   )r/   r5  s     r   test_it_retrieves_stored_refsz-TestRefResolver.test_it_retrieves_stored_refs*	  s    ]]$$T__5MM(D$6$67 6 .3BKL)]]$$%678Xr* 87	 65 87s   BB)B&)B2c                l   d}ddi}dt         j                  v r<| j                  t         j                  j                  dt         j                  d          t	        d|i      t         j                  d<   | j
                  j                  |      5 }| j                  |d       d d d        y # 1 sw Y   y xY w)Nhttp://bar#bazr[  r   requests
http://bar)r  modulesr'   __setitem__ReallyFakeRequestsr  ry  r(   )r/   r  r   r5  s       r   ,test_it_retrieves_unstored_refs_via_requestsz<TestRefResolver.test_it_retrieves_unstored_refs_via_requests2	  s    $OO''S[[5L #5lF5K"LJ]]$$S)XXr* *))s   B**B3c                    d}ddidt         j                  v r< j                  t         j                  j                  dt         j                  d          d t         j                  d<   t         fd       } j                  t
        t        dt        j                         |t        _         j                  j                  |      5 }	 d d d         j                  d       y # 1 sw Y   xY w)NrD  r[  r   rE  c              3     K   j                  | d       t        t        j                        j	                  d             y w)NrF  utf8)r(   r   jsondumpsencode)urlr   r/   s    r   fake_urlopenzQTestRefResolver.test_it_retrieves_unstored_refs_via_urlopen.<locals>.fake_urlopenI	  s6     S,/$**V,33F;<<s   AAurlopen)r  rG  r'   rH  r   setattrr   rS  r  ry  r(   )r/   r  rR  r5  r   s   `   @r   +test_it_retrieves_unstored_refs_via_urlopenz;TestRefResolver.test_it_retrieves_unstored_refs_via_urlopen?	  s    $OO''S[[5L #'J		= 
	= 	Y
8J8JK)
]]$$S)X *2& *)s   	C&&C/c                   t        j                  dd      5 }| j                  t        j                  |j
                         t        j                  ddi|       d d d        dt        j
                         d}| j                  j                  |      5 }| j                  |d       d d d        y # 1 sw Y   YxY w# 1 sw Y   y xY w)NFwt)deletemoder   r   zfile://z#foo)tempfileNamedTemporaryFiler'   osremover   rN  dumpr   r  ry  r(   )r/   tempfr  r5  s       r   (test_it_retrieves_local_refs_via_urlopenz8TestRefResolver.test_it_retrieves_local_refs_via_urlopenU	  s    ((DAUOOBIIuzz2IIuene, B UZZ016]]$$S)XXu- *) BA
 *)s   AB3B?3B<?Cc                   ddi}t         j                  j                  |d       }| j                  |j                  d       | j                  |j
                  d       |j                  d      5 }| j                  ||       d d d        |j                  d      5 }| j                  ||       d d d        |j                  d      5 }| j                  ||       d d d        |j                  d      5 }| j                  ||       d d d        y # 1 sw Y   xY w# 1 sw Y   nxY w# 1 sw Y   NxY w# 1 sw Y   y xY w)Nri   r   c                &    | j                  dd      S ro   rq   r0  s    r   ru   zPTestRefResolver.test_it_can_construct_a_base_uri_from_a_schema.<locals>.<lambda>b	  r;  r1   r<  rp   #zfoo#r   r  r=  r(   r0  resolution_scopery  r>  s       r   .test_it_can_construct_a_base_uri_from_a_schemaz>TestRefResolver.test_it_can_construct_a_base_uri_from_a_schema^	  s   **665 7 
 	**E222E:#xXv. $$Xv. %&(Xv. ''8Xv. (' $#$$&&''s0   0DDD(4D4DD%(D14D=c                   i }t         j                  j                  |      }| j                  |j                  d       | j                  |j
                  d       |j                  d      5 }| j                  ||       d d d        |j                  d      5 }| j                  ||       d d d        y # 1 sw Y   6xY w# 1 sw Y   y xY w)Nrp   rc  rd  r>  s       r   9test_it_can_construct_a_base_uri_from_a_schema_without_idzITestRefResolver.test_it_can_construct_a_base_uri_from_a_schema_without_ido	  s    **66v>**B/22B7#xXv. $$Xv. %$ $#$$s   +B3B?3B<?Cc                      fd}ddidt        j                  di d|i      }|j                        5 } j                  |       d d d        y # 1 sw Y   y xY w)Nc                ,    j                  |        S r3   rw  )rQ  r  r   r/   s    r   handlerz@TestRefResolver.test_custom_uri_scheme_handlers.<locals>.handlerz	  s    S#&Mr1   r   r   	foo://barrp   handlers)r   r  ry  r(   )r/   rk  r  r5  r  r   s   `   @@r   test_custom_uri_scheme_handlersz/TestRefResolver.test_custom_uri_scheme_handlersy	  s]    	 **2rUG<LM$Xv. %$$s   AA!c                     t               g fd}d}t        j                  di dd|i      }|j                  |      5  	 d d d        |j                  |      5  	 d d d        y # 1 sw Y   %xY w# 1 sw Y   y xY w)Nc                f    	 j                         S # t        $ r j                  d       Y y w xY w)Nz#Response must not have been cached!rV   
IndexErrorr    rQ  responser/   s    r   rk  z5TestRefResolver.test_cache_remote_on.<locals>.handler	  s3    A||~% A		?@A    00rl  rp   Tr   cache_remotern  r   r   r  ry  r/   rk  r  r  ru  s   `   @r   test_cache_remote_onz$TestRefResolver.test_cache_remote_on	  sx    H:	A **0@
 $ %$ %$ %$$$s   A(A4(A14A=c                     t               g fd}d}t        j                  di dd|i      }|j                  |      5  	 d d d        y # 1 sw Y   y xY w)Nc                f    	 j                         S # t        $ r j                  d       Y y w xY w)NzHandler called twice!rr  rt  s    r   rk  z6TestRefResolver.test_cache_remote_off.<locals>.handler	  s0    3||~% 3		123rv  rl  rp   Fr   rw  ry  rz  s   `   @r   test_cache_remote_offz%TestRefResolver.test_cache_remote_off	  sU    H:	3 **%1A
 $ %$$s   AAc                   t        d      fd}d}t        j                  di d|i      }| j                  t        j
                        5 }|j                  |      5  | j                  d       d d d        d d d        | j                  j                  t	        j
                               y # 1 sw Y   AxY w# 1 sw Y   ExY w)NzOh no! What's this?c                    r3   r   )rQ  r  s    r   rk  zTTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error.<locals>.handler	  s    Kr1   rl  rp   r   rm  zShouldn't get this far!)
rR  r   r  r   r   _RefResolutionErrorry  r    r(   rS  )r/   rk  r  r  errr  s        @r   3test_if_you_give_it_junk_you_get_a_resolution_errorzCTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error	  s    01	 **2rUG<LMz==>###C(		34 ) ? 	
(F(Fu(MN )( ?>s$   B=B11B=1B:	6B==Cc                "   t        j                  di       }|j                          | j                  t        j
                        5 }|j                          d d d        | j                  dt        j                               y # 1 sw Y   /xY w)Nrp   zFailed to pop the scope)	r   r  	pop_scoper   r   r  rz   ra  rS  )r/   r  excs      r   .test_helpful_error_message_on_failed_pop_scopez>TestRefResolver.test_helpful_error_message_on_failed_pop_scope	  sh    **2r2z==>#  ?/S]]1CD ?>s   BBc                   t         j                  j                  }t        j                  d|      }t        j                  ||      }| j	                  |j                  ddi             ddt         j                  j                  d   igi}t        j                  d|      }t        j                  ||      }| j	                  |j                  ddi             y)	z
        See #1085.
        rp   r  r/  r   allOfr   r$   N)r   r   r5   r  r  r   )r/   r   oner   anothertwos         r   ,test_pointer_within_schema_with_different_idz<TestRefResolver.test_pointer_within_schema_with_different_id	  s     ++77%%b&1..vD	++[%,@AB vz99EEeLMN
 %%b'2..wE	++[%,@ABr1   c                $     fd}t        j                  di d|i      }t        j                  i t         j                  j                        }ddd} |||	      } j                  |j                  i       |j                  d
      fd       y)zj
        See https://github.com/python-jsonschema/jsonschema/issues/1061#issuecomment-1624266555.
        c                0    j                  | d       ddiS )Nzhttp://example.com/foor   r   rw  )r  r/   s    r   handlezNTestRefResolver.test_newly_created_validator_with_ref_resolver.<locals>.handle	  s    S":;I&&r1   rp   httprm  r   zhttp://example.com/barr   )r$   r   r  r   FTN)r   r  r,   r   r4   r(   r   )r/   r  r  r-   r   r   s   `     r   .test_newly_created_validator_with_ref_resolverz>TestRefResolver.test_newly_created_validator_with_ref_resolver	  s    
	' **2rVV<LM%%!11<<
	 25Afx8	#Y%7%7%;<	
r1   c                    dddiidddiid}t        j                  |t        j                  d|            }| j                  |j	                  dd	i      |j	                  dd
i      fd       y)zj
        See https://github.com/python-jsonschema/jsonschema/issues/1124#issuecomment-1632574249.
        xr   z#/definitions/xr   r   )rz  r  rp   r  yr   r  N)r   r   r  r(   r   )r/   r   r   s      r   2test_refresolver_with_pointer_in_schema_with_no_idzBTestRefResolver.test_refresolver_with_pointer_in_schema_with_no_id	  s     ): ;<&)!45

 33,,R8
	 	c
+Y-?-?b	-JK	
r1   N)rW   r   rX   r0  r.  r/  r0   r6  r8  r?  rB  rJ  rU  r`  rf  rh  ro  r{  r~  r  r  r  r  r  r   r1   r   r*  r*  	  st    HJx(M
)K	4++',./"/	/$ OEC 
*
r1   r*  c                "    d }t        | |      S )Nc                    | j                   D cg c]  }t        |       c}| j                  D cg c]  }t        |       c}fS c c}w c c}w r3   )r  ra  rD   )r  r  s     r   keyzsorted_errors.<locals>.key	  sJ    "ZZ(ZSVZ("../.SV./
 	
(/s
   AA)r  )sorted)r   r  s     r   r  r  	  s    

 &c""r1   c                      e Zd ZU ded<   d Zy)rI  zdict[str, Any]
_responsesc                    | j                   j                  |      }|t        dt        |      z         t	        t        j                  |            S )NzUnknown URL: )r  rr   rR  r\   _ReallyFakeJSONResponserN  rO  )r/   rQ  ru  s      r   rr   zReallyFakeRequests.get
  sC    ??&&s+;_tCy899&tzz(';<<r1   N)rW   r   rX   r  rr   r   r1   r   rI  rI  	  s     =r1   rI  c                      e Zd ZU ded<   d Zy)r  ra  	_responsec                @    t        j                  | j                        S r3   )rN  loadsr  r.   s    r   rN  z_ReallyFakeJSONResponse.json
  s    zz$..))r1   N)rW   r   rX   r  rN  r   r1   r   r  r  	
  s     N*r1   r  ):
__future__r   collectionsr   r   
contextlibr   decimalr   ior   typingr	   unittestr
   r   urllib.requestr   rN  r\  r  rZ  r  attrsr   r   referencing.jsonschemar   referencing.exceptionsr#  
jsonschemar   r   r   r   r   r    r"   r   r  r  r  r}  r  r  r  r  r  r  r  r  r  r  r  r*  r  rI  r  r   r1   r   <module>r     s   " ) %    # '  	 
    .  1L6( L6^~
( ~
BL
 L
^5
 5
pwE- wEtJ J4H-/A8 H@)-/A8 )),h )),h ))18 ))18 )%( %LJx LJ^^M8 ^MBCH C>h 4l
h l
`# = = = * * *r1   