
    {gHS                      S SK Jr  S SKJrJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJrJr  S SKJr  S S	KrS S	KrS S	KrS S	KrS S	KrS S
KJrJr  S SKJr  S S	KrS SKJrJ r J!r!J"r"J#r#  S r$ " S S\5      r% " S S\5      r& " S S\5      r' " S S5      r( " S S\(5      r) " S S5      r* " S S\*\)\5      r+ " S S\*\)\5      r, " S S\)\5      r- " S  S!\)\5      r. " S" S#\)\5      r/ " S$ S%\)\5      r0 " S& S'\5      r1 " S( S)\5      r2 " S* S+\5      r3 " S, S-\5      r4 " S. S/\5      r5 " S0 S1\5      r6S2 r7\ " S3 S45      5       r8\ " S5 S65      5       r9g	)7    )annotations)deque
namedtuple)contextmanager)Decimal)BytesIO)Any)TestCasemock)pathname2urlN)definefield)DRAFT202012)FormatCheckerTypeChecker
exceptions	protocols
validatorsc              #  r   #    U H-  nUR                  SS5        [        R                  " S0 UD6v   M/     g 7f)NmessagezYou told me to fail! )
setdefaultr   ValidationError)	validatorerrorsinstanceschemaeachs        B/usr/lib/python3/dist-packages/jsonschema/tests/test_validators.pyfailr       s2     	#9:((0400 s   57c                      \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rSrg)TestCreateAndExtend#   c                   U R                  U R                  [        R                  [	        [        R                  5      5        U R                  U R                  [        R
                  [	        [        R
                  5      5        SS0U l        S[        0U l        [        5       U l	        [        R                  " U R                  U R                  U R                  S9U l        g )N$idzsome://meta/schemar    )meta_schemar   type_checker)
addCleanupassertEqualr   _META_SCHEMASdict_VALIDATORSr&   r    r   r'   create	Validatorselfs    r   setUpTestCreateAndExtend.setUp$   s    $$))*	

 	""''(	
 "#78!4.'M#**((**
    c                    U R                  U R                  R                  U R                  R                  U R                  R                  4U R
                  U R                  U R                  45        g N)r)   r.   
VALIDATORSMETA_SCHEMATYPE_CHECKERr   r&   r'   r/   s    r   
test_attrsTestCreateAndExtend.test_attrs9   s\    ))**++
   !!
	
r3   c                b    S/ 0nU R                  U R                  U5      R                  U5        g )Nr    )r)   r.   r   r0   r   s     r   	test_initTestCreateAndExtend.test_initF   s*    "/66?r3   c                    S/ 0nU R                  U5      n[        UR                  S5      5      nU R                  U/ 5        g )Nr    hello)r.   listiter_errorsr)   r0   r   r   r   s       r   test_iter_errors_successful/TestCreateAndExtend.test_iter_errors_successfulJ   s>    "NN6*	i++G45$r3   c           
     L   SSS0/0nU R                  U5      n[        R                  " SSUSSS0/[        S/5      S9n[	        UR                  S5      5      nU R                  [        U5      S5        U R                  US   R                  5       UR                  5       5        g )Nr    r   zWhoops!goodbye)r   r   r   validator_valueschema_path   r   )	r.   r   r   r   rA   rB   r)   len	_contents)r0   r   r   expected_errorr   s        r   test_iter_errors_one_error.TestCreateAndExtend.test_iter_errors_one_errorQ   s    Iy123NN6*	#33'34vh
 i++I67Va(,,.0H0H0JKr3   c                    SSS0SSS.SS0/0nU R                  U5      n[        UR                  S5      5      nU R                  [	        U5      S	5        g )
Nr    r   FirstzSecond!asdf)r   r   ThirdrG      )r.   rA   rB   r)   rK   rC   s       r    test_iter_errors_multiple_errors4TestCreateAndExtend.test_iter_errors_multiple_errorsb   sb    G$%F;G$
 NN6*	i++I67Va(r3   c                J   [         R                  " SS0SS9nU R                  [         R                  R                  S5        U R                  [         R
                  R                  S5        U R                  UR                  S5        U R                  UR                  S5        g )Nr%   	something
my versionr&   versionMyVersionValidator)	r   r-   r(   r*   popr,   r)   __name____qualname__r0   r.   s     r   .test_if_a_version_is_provided_it_is_registeredBTestCreateAndExtend.test_if_a_version_is_provided_it_is_registeredo   s    %%, 
	 	
0044kB
..22LA++-AB//1EFr3   c                   [         R                  " SS0SS9nU R                  [         R                  R                  S5        U R                  [         R
                  R                  S5        U R                  [        U" 0 5      5      S5        g )Nr%   rX   rY   rZ   z2MyVersionValidator(schema={}, format_checker=None))r   r-   r(   r*   r]   r,   r)   reprr`   s     r   	test_reprTestCreateAndExtend.test_repry   sp    %%, 
	 	
0044kB
..22LA2@	
r3   c                D   [         R                  " SS0SS9nU R                  [         R                  R                  S5        U R                  [         R
                  R                  S5        U R                  [        U" S[        [        S5      5      05      5      S5        g )Nr%   rX   rY   rZ   ai  zNMyVersionValidator(schema={'a': [0, 1, 2, 3, 4, 5, ...]}, format_checker=None))
r   r-   r(   r*   r]   r,   r)   rd   rA   ranger`   s     r   test_long_repr"TestCreateAndExtend.test_long_repr   s    %%, 
	 	
0044kB
..22LACeDk!2345'	
r3   c                n    [         R                  " 0 S9nU R                  [        U" 0 5      5      S5        g )Nr&   z)Validator(schema={}, format_checker=None))r   r-   r)   rd   r`   s     r   test_repr_no_version(TestCreateAndExtend.test_repr_no_version   s/    %%"5	27	
r3   c                   [         R                  " SS0SS9nU R                  [         R                  R                  S5        U R                  [         R
                  R                  S5        U R                  UR                  S5        g )Nr%   rX   zfoo-barrZ   FooBarValidator)r   r-   r(   r*   r]   r,   r)   r_   r`   s     r   -test_dashes_are_stripped_from_validator_namesATestCreateAndExtend.test_dashes_are_stripped_from_validator_names   sj    %%,
	 	
0044kB
..22I>//1BCr3   c                    [        [        R                  5      n[        R                  " SS0S9  U R	                  [        R                  U5        g )Nidrm   )r+   r   r*   r-   r)   )r0   originals     r   6test_if_a_version_is_not_provided_it_is_not_registeredJTestCreateAndExtend.test_if_a_version_is_not_provided_it_is_not_registered   s:    
001tTl3118<r3   c                &   SnSU0n[         R                  " USS S9  U R                  [         R                  R                  U5        U R                  [         R
                  R                  S5        U R                  U[         R                  5        g )Nmeta schema idru   rY   c                &    U R                  SS5      $ Nru    getss    r   <lambda>MTestCreateAndExtend.test_validates_registers_meta_schema_id.<locals>.<lambda>       AEE$Or3   r&   r[   id_ofr   r-   r(   r*   r]   r,   assertInr0   meta_schema_keymy_meta_schemas      r   'test_validates_registers_meta_schema_id;TestCreateAndExtend.test_validates_registers_meta_schema_id   sr    *0& +	

 	
0044oF
..22LAoz'?'?@r3   c                "   SnSU0n[         R                  " USS9  U R                  [         R                  R                  U5        U R                  [         R
                  R                  S5        U R                  U[         R                  5        g )Nmeta schema $idr%   rY   rZ   r   r   s      r   .test_validates_registers_meta_schema_draft6_idBTestCreateAndExtend.test_validates_registers_meta_schema_draft6_id   so    +1& 	
 	
0044oF
..22LAoz'?'?@r3   c                   ^ [         R                  " 0 SS9mU R                  [        U4S jS/ 4SSSSS	0 4S
4 5       5      5        g )Nr   r&   r   c              3  R   >#    U  H  u  pT" 0 5      R                  X!S 9v   M     g7f))r   typeN)is_type).0r   r   r.   s      r   	<genexpr>@TestCreateAndExtend.test_create_default_types.<locals>.<genexpr>   s0      'ND "%%x%C's   $'array)booleanT)integer   )nullN)numberg      (@object)stringfoo)r   r-   
assertTrueallr`   s    @r   test_create_default_types-TestCreateAndExtend.test_create_default_types   sW    %%"D	  bM%#"$rN%' 	
r3   c                X   [         R                  " [         R                  R                  S   S0 0S.S9nUR	                  SS05        U R                  [        R                  5         UR	                  0 5        SSS5        U" SS05      R                  S5        g! , (       d  f       N(= f)zY
One can create a validator class whose metaschema uses a different
dialect than itself.
r%   const)$schemanotrm   r   barN)	r   r-   Draft202012Validatorr7   check_schemaassertRaisesr   SchemaErrorvalidater0   NoEmptySchemasValidators     r   +test_check_schema_with_different_metaschema?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                    [         R                  " SSS0/0S[        0S9nU R                  [        R
                  5         UR                  0 5        SSS5        g! , (       d  f       g= f)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_selfPTestCreateAndExtend.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                   [        U R                  R                  5      n[        5       n[        R
                  " U R                  SU0S9nU R                  UR                  UR                  UR                  U R                  R                  4[        XS9U R                  R                  U R                  R                  U45        g )Nnew)r   )r   )	r+   r.   r6   r   r   extendr)   r7   r8   )r0   rv   r   Extendeds       r   test_extendTestCreateAndExtend.test_extend   s    112h$$NNs|
 	##$$%%))	 X'**++		
r3   c                N  ^  U 4S jnSnSUS.n[         R                  " UT R                   T R                  US9nT R                  UR	                  UR
                  5      U5        [         R                  " U5      nT R                  UR	                  UR
                  5      U5        g)z;
Extending a validator preserves its notion of schema IDs.
c                Z   > U R                  STR                  R                  U 5      5      $ )N__test__)r   r.   ID_OF)r   r0   s    r   r   3TestCreateAndExtend.test_extend_idof.<locals>.id_of  s#    ::j$..*>*>v*FGGr3   zthe://correct/id/zthe://wrong/id/)r%   r   )r&   r   r'   r   N)r   r-   r'   r)   r   r7   r   )r0   r   
correct_idr&   OriginalDeriveds   `     r   test_extend_idof$TestCreateAndExtend.test_extend_idof
  s    	H(
$"
 $$#**	
 	(<(<=zJ##H-w':':;ZHr3   c                   SSS00SSS.n[         R                  " U5      nU R                  UR                  S5      5        [         R                  " [         R                  5      nU R                  U" U5      R                  S5      5        g)	zF
Extending a validator preserves its notion of applicable validators.
testr   r   z#/$defs/testrJ   )$defs$refmaximum%   N)r   Draft4Validatorr   is_validr   )r0   r   draft4r   s       r   !test_extend_applicable_validators5TestCreateAndExtend.test_extend_applicable_validators   sv     vx01"
 ++F3+,##J$>$>?0045r3   )r.   r&   r'   r   N)r^   
__module__r_   __firstlineno__r1   r9   r=   rD   rN   rU   ra   re   rj   rn   rr   rw   r   r   r   r   r   r   r   r   __static_attributes__r   r3   r   r"   r"   #   sn    
*
@%L")G



D=
AA
"@&5
,I,6r3   r"   c                  L   \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S+ r-S, r.S- r/S. r0S/ r1S0 r2S1 r3S2 r4S3 r5S4 r6S5 r7S6r8g7)8TestValidationErrorMessagesi2  c                2   UR                  S[        R                  5      nUR                  U5        U" U/UQ70 UD6n[	        UR                  U5      5      nU R                  USU< 3S9  U R                  [        U5      SSU< 3S9  US   R                  $ )NclszNo errors were raised for )msgrJ   z"Expected exactly one error, found r   )
r]   r   _LATEST_VERSIONr   rA   rB   r   r)   rK   r   )r0   r   r   argskwargsr   r   r   s           r   message_for'TestValidationErrorMessages.message_for3  s    jj
 : :; 000	i++H56&@$MNK4VJ? 	 	

 ay   r3   c                L    U R                  SSS0S9nU R                  US5        g NrJ   r   r   r   r   1 is not of type 'string'r   r)   r0   r   s     r   test_single_type_failure4TestValidationErrorMessages.test_single_type_failure@  s-    ""Avx6H"I"=>r3   c                N    U R                  SSS/0S9nU R                  US5        g r   r   r   s     r   test_single_type_list_failure9TestValidationErrorMessages.test_single_type_list_failureD  s/    ""Avz6J"K"=>r3   c                b    SnU R                  SS[        U5      0S9nU R                  US5        g )N)r   r   rJ   r   r   z#1 is not of type 'string', 'object')r   rA   r)   )r0   typesr   s      r   test_multiple_type_failure6TestValidationErrorMessages.test_multiple_type_failureH  s6    """AvtE{6K"L"GHr3   c                v    SSSS./0nU R                  SU[        R                  S9nU R                  US5        g )Nr   FoorT   )nameminimumrJ   r   r   r   z1 is not of type 'Foo'r   r   Draft3Validatorr)   r0   r   r   s      r   #test_object_with_named_type_failure?TestValidationErrorMessages.test_object_with_named_type_failureM  sK    Ea89:""** # 

 	":;r3   c                L    U R                  SSS0S9nU R                  US5        g )NrJ   r      r   z1 is less than the minimum of 2r   r   s     r   test_minimum(TestValidationErrorMessages.test_minimumV  s,    ""Ay!n"E"CDr3   c                L    U R                  SSS0S9nU R                  US5        g )NrJ   r   r   r   z"1 is greater than the maximum of 0r   r   s     r   test_maximum(TestValidationErrorMessages.test_maximumZ  s,    ""Ay!n"E"FGr3   c                |    Su  pSX00nU R                  SS0U[        R                  S9nU R                  US5        g Nr   r   dependenciesr   r   r   z'foo' is a dependency of 'bar'r   r0   dependonr   r   s        r    test_dependencies_single_element<TestValidationErrorMessages.test_dependencies_single_element^  sP    !
 6,/""QZ** # 

 	"BCr3   c                z    SSS0/0nU R                  SSU/0[        R                  S9nU R                  US5        g )Nr   r   rT   rJ   r   z+1 is not of type {'type': [{'minimum': 3}]}r   )r0   r   r   s      r   -test_object_without_title_type_failure_draft3ITestValidationErrorMessages.test_object_without_title_type_failure_draft3h  sT    )Q()""TF#** # 

 	9	
r3   c                ~    Su  pSX/00nU R                  SS0U[        R                  S9nU R                  US5        g r  r   r  s        r   test_dependencies_list_draft39TestValidationErrorMessages.test_dependencies_list_draft3t  R    !
 64.1""QZ** # 

 	"BCr3   c                ~    Su  pSX/00nU R                  SS0U[        R                  S9nU R                  US5        g r  r   r   Draft7Validatorr)   r  s        r   test_dependencies_list_draft79TestValidationErrorMessages.test_dependencies_list_draft7~  r  r3   c                n    U R                  S// SS.[        R                  S9nU R                  SU5        g )Nr   FitemsadditionalItemsr   z(2 was unexpected)r   r   r   r   r   s     r   #test_additionalItems_single_failure?TestValidationErrorMessages.test_additionalItems_single_failure  s>    ""SE:** # 

 	*G4r3   c                p    U R                  / SQ/ SS.[        R                  S9nU R                  SU5        g )NrJ   r   rT   Fr  r   z(1, 2, 3 were unexpected)r  r   s     r   &test_additionalItems_multiple_failuresBTestValidationErrorMessages.test_additionalItems_multiple_failures  s<    ""E:** # 

 	17;r3   c                X    SnSS0nU R                  US0US9nU R                  SU5        g )Nr   additionalPropertiesFr   r   z('foo' was unexpected)r   r   )r0   
additionalr   r   s       r   (test_additionalProperties_single_failureDTestValidationErrorMessages.test_additionalProperties_single_failure  s9    
(%0""ZOF"K.8r3   c                    SS0nU R                  [        R                  SS/5      US9nU R                  [	        S5      U5        U R                  [	        S5      U5        U R                  SU5        g )Nr!  Fr   r   r   zwere unexpected))r   r+   fromkeysr   rd   r   s      r   +test_additionalProperties_multiple_failuresGTestValidationErrorMessages.test_additionalProperties_multiple_failures  si    (%0""]]E5>2 # 

 	d5k7+d5k7+('2r3   c                T    SS0nU R                  SS0US9nU R                  SU5        g )Nr   r   r   r   r   z12 was expectedr"  r   s      r   
test_const&TestValidationErrorMessages.test_const  s;    2""U^ # 
 	'1r3   c                x    SSS00nU R                  S0 / /U[        R                  S9nU R                  US5        g )Ncontainsr   r   r   r   z4None of [2, {}, []] are valid under the given schema)r   r   Draft6Validatorr)   r   s      r   test_contains_draft_61TestValidationErrorMessages.test_contains_draft_6  sP    wm,""R[** # 

 	B	
r3   c                    [        SS9nUR                  S5      " S 5        SS0nU R                  SUUS9nU R                  [	        S5      U5        U R                  [	        S5      U5        U R                  SU5        g )	Nr   )formatsthingc                    gNFr   )values    r   r   QTestValidationErrorMessages.test_invalid_format_default_message.<locals>.<lambda>  s    er3   formatbla)r   r   format_checkerzis not a)r   checksr   r   rd   )r0   checkerr   r   s       r   #test_invalid_format_default_message?TestValidationErrorMessages.test_invalid_format_default_message  sz    +w 34G$""" # 
 	d5k7+d7mW-j'*r3   c                   SSSS0SS0S.S.nU R                  SS0U[        R                  S	9nU R                  US
R	                  [        S5      [        S5      [        S5      5      5        U R                  SSS.U[        R                  S	9nU R                  USR	                  [        S5      [        S5      [        S5      [        S5      5      5        g )Nr   Fr   r   )^abc$^def$)r   r!  patternPropertieszebra{   r   z,{} does not match any of the regexes: {}, {}rA  rB  i  )rD  fishz.{}, {} do not match any of the regexes: {}, {}rF  )r   r   r   r)   r9  rd   r   s      r   1test_additionalProperties_false_patternPropertiesMTestValidationErrorMessages.test_additionalProperties_false_patternProperties  s    "*/ &1 &1( ""s^** # 

 	:AAWtG}d7m	
 """C0** # 

 	<CCVd7mT']DM	
r3   c                H    U R                  SSS9nU R                  US5        g )NrX   Fr   z'False schema does not allow 'something'r   r   s     r   test_False_schema-TestValidationErrorMessages.test_False_schema  s0    ""  # 
 	"KLr3   c                L    U R                  SSS0S9nU R                  US5        g )NrT   
multipleOfr   r   z3 is not a multiple of 2r   r   s     r   test_multipleOf+TestValidationErrorMessages.test_multipleOf  s5    "" !$ # 
 	"<=r3   c                L    U R                  / SS0S9nU R                  US5        g )NminItemsr   r   z[] is too shortr   r   s     r   test_minItems)TestValidationErrorMessages.test_minItems  s,    ""B
A"G"34r3   c                P    U R                  / SQSS0S9nU R                  US5        g )Nr  maxItemsr   r   z[1, 2, 3] is too longr   r   s     r   test_maxItems)TestValidationErrorMessages.test_maxItems  s,    ""Iz1o"N"9:r3   c                V    U R                  / SQS0 0 /S.S9nU R                  US5        g )N)rJ   r   r   Fr  prefixItemsr   z1Expected at most 2 items but found 1 extra: 'foo'r   r   s     r   test_prefixItems_with_items7TestValidationErrorMessages.test_prefixItems_with_items   s<    """"B8< # 
 	?	
r3   c                V    U R                  / SQS0 0 /S.S9nU R                  US5        g )NrJ   r   r      FrY  r   z6Expected at most 2 items but found 2 extra: ['foo', 5]r   r   s     r   *test_prefixItems_with_multiple_extra_itemsFTestValidationErrorMessages.test_prefixItems_with_multiple_extra_items
  s<    ""%"B8< # 
 	D	
r3   c                L    U R                  SSS0S9nU R                  US5        g )Nr}   	minLengthr   r   z'' is too shortr   r   s     r   test_minLength*TestValidationErrorMessages.test_minLength  s5    ""# # 
 	"34r3   c                L    U R                  SSS0S9nU R                  US5        g )Nabc	maxLengthr   r   z'abc' is too longr   r   s     r   test_maxLength*TestValidationErrorMessages.test_maxLength  s5    ""# # 
 	"56r3   c                L    U R                  SSS0S9nU R                  US5        g )Nbbbpatternz^a*$r   z'bbb' does not match '^a*$'r   r   s     r   test_pattern(TestValidationErrorMessages.test_pattern"  s5    ""v& # 
 	"?@r3   c                P    U R                  / SSS00S9nU R                  US5        g )Nr.  r   r   r   z3[] does not contain items matching the given schemar   r   s     r   test_does_not_contain1TestValidationErrorMessages.test_does_not_contain)  s=    "" 23 # 
 	A	
r3   c                V    U R                  SS/SS0SS.S9nU R                  US5        g )	Nr   rJ   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_few1TestValidationErrorMessages.test_contains_too_few3  sC    ""QZ!' 21E # 
 	7	
r3   c                X    U R                  SS/SS0SSS.S9nU R                  US	5        g )
Nr   rJ   r   r   r      r.  ru  maxContainsr   rv  r   r   s     r   &test_contains_too_few_both_constrainedBTestValidationErrorMessages.test_contains_too_few_both_constrained>  sI    ""QZ#X.   # 
 		
r3   c                V    U R                  / SQSS0SS.S9nU R                  US5        g )Nr   r   bazr   r   r   r.  r|  r   :Too many items match the given schema (expected at most 2)r   r   s     r   test_contains_too_many2TestValidationErrorMessages.test_contains_too_manyM  s=    ""*!' 21E # 
 	H	
r3   c                \    U R                  S/S-  SS0SSS.S9nU R                  US	5        g )
Nr   r_  r   r   r   rz  r{  r   z:Too many items match the given schema (expected at most 4)r   r   s     r   'test_contains_too_many_both_constrainedCTestValidationErrorMessages.test_contains_too_many_both_constrainedW  sI    ""Wq[#X.   # 
 	H	
r3   c                L    U R                  SSS0S9nU R                  US5        g )NrT   exclusiveMinimumr_  r   z+3 is less than or equal to the minimum of 5r   r   s     r   test_exclusiveMinimum1TestValidationErrorMessages.test_exclusiveMinimume  s8    ""&* # 
 	9	
r3   c                L    U R                  SSS0S9nU R                  US5        g )NrT   exclusiveMaximumr   r   z.3 is greater than or equal to the maximum of 2r   r   s     r   test_exclusiveMaximum1TestValidationErrorMessages.test_exclusiveMaximumo  s1    ""A7I16M"N<	
r3   c                N    U R                  0 SS/0S9nU R                  US5        g )Nrequiredr   r   z'foo' is a required propertyr   r   s     r   test_required)TestValidationErrorMessages.test_requiredv  s/    ""B
UG7L"M"@Ar3   c                V    U R                  S0 0SSS/00S9nU R                  US5        g )Nr   dependentRequiredr   r   z'bar' is a dependency of 'foo'r   r   s     r   test_dependentRequired2TestValidationErrorMessages.test_dependentRequiredz  s@    ""R['%%)9: # 
 	"BCr3   c                L    U R                  0 SS0S9nU R                  US5        g )NminPropertiesr   r   z"{} does not have enough propertiesr   r   s     r   test_minProperties.TestValidationErrorMessages.test_minProperties  s-    ""B7K"L"FGr3   c                T    U R                  0 0 0 S.SS0S9nU R                  US5        g )N)rh   bcmaxPropertiesr   r   z3{'a': {}, 'b': {}, 'c': {}} has too many propertiesr   r   s     r   test_maxProperties.TestValidationErrorMessages.test_maxProperties  s?    ""BR0#Q' # 
 	A	
r3   c                N    U R                  0 SS/0S9nU R                  US5        g )NoneOfFr   z.{} is not valid under any of the given schemasr   r   s     r   test_oneOf_matches_none3TestValidationErrorMessages.test_oneOf_matches_none  s2    ""B%7I"J<	
r3   c                P    U R                  0 SSS/0S9nU R                  US5        g )Nr  Tr   z${} is valid under each of True, Truer   r   s     r   test_oneOf_matches_too_many7TestValidationErrorMessages.test_oneOf_matches_too_many  s1    ""B$7N"O"HIr3   c                V    SSS.nU R                  SS/US9nU R                  US5        g )Nr   Fr   unevaluatedItemsr   r   r   z@Unevaluated items are not allowed ('foo', 'bar' were unexpected)r"  r   s      r   test_unevaluated_items2TestValidationErrorMessages.test_unevaluated_items  s7    !u=""UEN6"JN	
r3   c                R    SSS.nU R                  SUS9nU R                  US5        g )Nr   Fr  r   r   z'foo' is not of type 'array'r   r   s      r   &test_unevaluated_items_on_invalid_typeBTestValidationErrorMessages.test_unevaluated_items_on_invalid_type  s2    !u=""E&"A"@Ar3   c                f    SSS00SS0S.nU R                  SSSS.US	9nU R                  US
5        g )Nr   r   r   r   r   
propertiesunevaluatedPropertiesr   r  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_subschemaQTestValidationErrorMessages.test_unevaluated_properties_invalid_against_subschema  s_     68"45&-r]
 ""
  # 
 	2	
r3   c                X    SSS.nU R                  SSS.US9nU R                  US5        g )	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_disallowedBTestValidationErrorMessages.test_unevaluated_properties_disallowed  sI    "UC""  # 
 	-	
r3   c                R    SSS.nU R                  SUS9nU R                  US5        g )Nr   Fr  r   r   z'foo' is not of type 'object'r   r   s      r   +test_unevaluated_properties_on_invalid_typeGTestValidationErrorMessages.test_unevaluated_properties_on_invalid_type  s2    "UC""E&"A"ABr3   c                X    0 /SS.nU R                  / SQUS9nU R                  US5        g )NFrZ  r  r  r   z9Expected at most 1 item but found 2 extra: ['bar', 'baz']r   r   s      r   test_single_item,TestValidationErrorMessages.test_single_item  s?    "$6""* # 
 	G	
r3   c                v    0 /SS.nU R                  / SQU[        R                  S9nU R                  US5        g )NFr  r   r   r   r   z<Additional items are not allowed ('bar', 37 were unexpected)r  r   s      r   -test_heterogeneous_additionalItems_with_ItemsITestValidationErrorMessages.test_heterogeneous_additionalItems_with_Items  sH    4E:""'** # 

 	J	
r3   c                X    0 /SS.nU R                  / SQUS9nU R                  US5        g )NFr  r  r   z6Expected at most 1 item but found 2 extra: ['bar', 37]r   r   s      r   $test_heterogeneous_items_prefixItems@TestValidationErrorMessages.test_heterogeneous_items_prefixItems  s?    "$6""' # 
 	D	
r3   c                X    0 /SS.nU R                  / SQUS9nU R                  US5        g )NF)rZ  r  r  r   z=Unevaluated items are not allowed ('bar', 37 were unexpected)r   r   s      r   /test_heterogeneous_unevaluatedItems_prefixItemsKTestValidationErrorMessages.test_heterogeneous_unevaluatedItems_prefixItems  s?    "$5A""' # 
 	K	
r3   c                ^    S0 0SS.nU R                  0 SSS.US9nU R                  US5        g	)
;
Not valid deserialized JSON, but this should not blow up.
r   F)r  r!  r  r   r   rh   r   r   z?Additional properties are not allowed (37, 'a' were unexpected)Nr   r   s      r   2test_heterogeneous_properties_additionalPropertiesNTestValidationErrorMessages.test_heterogeneous_properties_additionalProperties  sJ     "'UK""e4 # 
 	M	
r3   c                ^    S0 0SS.nU R                  0 SSS.US9nU R                  US5        g	)
r  r   Fr  r  r   r  r   z@Unevaluated properties are not allowed (37, 'a' were unexpected)Nr   r   s      r   3test_heterogeneous_properties_unevaluatedPropertiesOTestValidationErrorMessages.test_heterogeneous_properties_unevaluatedProperties	  sJ     "'eL""e4 # 
 	N	
r3   r   N)9r^   r   r_   r   r   r   r   r   r   r   r   r  r
  r  r  r  r  r$  r(  r+  r0  r>  rG  rJ  rN  rR  rV  r[  r`  rd  ri  rn  rq  rw  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r3   r   r   r   2  s   !??I
<EHD

DD5<9	32

+
<M>5;

57A
	





BDH

J
B

&
C
	


	
	


r3   r   c                      \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rSrg)TestValidationErrorDetailsi  c                6   SnSSS0SS0/0n[         R                  " U5      n[        UR                  U5      5      nU R	                  [        U5      S5        US   nU R	                  UR                  S5        U R	                  UR                  US   5        U R	                  UR                  U5        U R	                  UR                  U5        U R                  UR                  5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                   S	5        U R	                  UR"                  [        S/5      5        U R	                  UR$                  [        S/5      5        U R	                  UR&                  [        S/5      5        U R	                  [        UR(                  5      S
5        [+        UR(                  5      u  pgU R	                  UR                  S5        U R	                  UR                  US   S   S   5        U R	                  UR                  U5        U R	                  UR                  US   S   5        U R-                  UR                  U5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                   S	5        U R	                  UR"                  [        SS/5      5        U R	                  UR$                  [        SS/5      5        U R	                  UR&                  [        / SQ5      5        U R/                  UR(                  5        U R	                  UR                  S5        U R	                  UR                  US   S   S   5        U R	                  UR                  U5        U R	                  UR                  US   S   5        U R-                  UR                  U5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                   S	5        U R	                  UR"                  [        SS/5      5        U R	                  UR$                  [        SS/5      5        U R	                  UR&                  [        / SQ5      5        U R	                  [        UR(                  5      S5        g )Nr_  anyOfr      r   r   rJ   r   $r   )r  r   r   )r  rJ   r   )r   r   rA   rB   r)   rK   r   rH   r   r   assertIsNoneparentpathr   relative_pathabsolute_path	json_pathrI   relative_schema_pathabsolute_schema_pathcontextsorted_errorsassertIsassertFalser0   r   r   r   r   ee1e2s           r   
test_anyOf%TestValidationErrorDetails.test_anyOf  s?   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)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!,r3   c                "   SS0nSSS0SSSS/00S./0n[         R                  " U5      n[        UR                  U5      5      nU R	                  [        U5      S5        US	   nU R	                  UR                  S5        U R	                  UR                  US   5        U R	                  UR                  U5        U R	                  UR                  U5        U R                  UR                  5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                   S
5        U R	                  UR"                  [        S/5      5        U R	                  UR$                  [        S/5      5        U R	                  UR&                  [        S/5      5        U R	                  [        UR(                  5      S5        [+        UR(                  5      u  pgU R	                  UR                  S5        U R	                  UR                  US   S	   S   5        U R	                  UR                  U5        U R	                  UR                  US   S	   5        U R-                  UR                  U5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                  [        / 5      5        U R	                  UR                   S
5        U R	                  UR"                  [        S	S/5      5        U R	                  UR$                  [        S	S/5      5        U R	                  UR&                  [        / SQ5      5        U R/                  UR(                  5        U R	                  UR                  S5        U R	                  UR                  S/5        U R	                  UR                  S5        U R	                  UR                  SS/05        U R-                  UR                  U5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                   S5        U R	                  UR"                  [        / SQ5      5        U R	                  UR$                  [        / SQ5      5        U R	                  UR&                  [        / SQ5      5        U R/                  UR(                  5        g )Nr   rJ   r   r   r   enumr   r   r  r   r  )r   r   r   $.foo)rJ   r  r   r  )r   rJ   r  r   r  )r   r   rA   rB   r)   rK   r   rH   r   r   r  r  r  r   r  r  r  rI   r  r  r  r  r  r  r  s           r   	test_type$TestValidationErrorDetails.test_type`  sE   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)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	
 	##:;	

 	$r3   c                   SS/SSS.nSSS0S	S0S
/ SQS.S.0n[         R                  " U5      nUR                  U5      n[        U5      u  pVpxU R	                  UR
                  [        S/5      5        U R	                  UR
                  [        S/5      5        U R	                  UR
                  [        S/5      5        U R	                  UR
                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        S/5      5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S	5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        g )Nr   rJ      spam)r   r   r  quuxr  r   r   rQ  
   )r   rz        )r   r  r  r   r  r   $.barz$.bazr  r  r   )r   r   rB   r  r)   r  r   r  r  r  r   )	r0   r   r   r   r   r  r  e3e4s	            r   test_single_nesting.TestValidationErrorDetails.test_single_nesting  sP   aSVD)"A#%|<
 ..v6	&&x0&v.%.1%.1%.1%.1))5%>:))5%>:))5%>:))5%>:))5%>:))5%>:))5%>:))5%>:w/w/w/w/z2v.y1v.r3   c                   SSSS/0S.S/nSSS/SSS	/0S
SS0SS0S.S.S.S.S.n[         R                  " U5      nUR                  U5      n[        U5      u  pVpxpU R	                  UR
                  [        / 5      5        U R	                  UR
                  [        S/5      5        U R	                  UR
                  [        SS/5      5        U R	                  UR
                  [        / SQ5      5        U R	                  U	R
                  [        / SQ5      5        U R	                  U
R
                  [        SS/5      5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  U	R                  S5        U R	                  U
R                  S5        U R	                  UR                  [        S/5      5        U R	                  UR                  [        SS/5      5        U R	                  [        UR                  5      / SQ5        U R	                  [        UR                  5      / SQ5        U R	                  [        U	R                  5      / S Q5        U R	                  [        U
R                  5      / S!Q5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  U	R                  S5        U R	                  U
R                  S5        g )"NrJ   r   r  r  r  r   r   r  rT   r   r  TrQ  )r   r  r  )r   r  r   r   )rJ   r   r   )rJ   r   r  r   r  $[0]z$[1].barz$[1].bar.barz$[1].bar.bazz$[1].foor   r  )r  r  r   r   )r  r  r   r  r   r  )r  r  r   r  r  rQ  )r  r  r   r  )r   r   rB   r  r)   r  r   r  rI   rA   r   )r0   r   r   r   r   r  r  r  r  e5e6s              r   test_multiple_nesting0TestValidationErrorDetails.test_multiple_nesting  s   q%!6?!8,"QF+ '$.#5$.?'	
" ..v6	&&x0!.v!6%),%*-%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.r3   c           	     n   SSSSS/SS0SSS	S
00S.S.S./00SS/SS	S
00S.nSSSSSSS00S.0S.0n[         R                  " U5      nUR                  U5      u  nU R                  UR                  [        S/5      5        U R                  UR                  [        / SQ5      5        U R                  UR                  S5        UR                  u  nU R                  UR                  [        / SQ5      5        U R                  UR                  [        / SQ5      5        U R                  UR                  S5        UR                  u  nU R                  UR                  [        / SQ5      5        U R                  UR                  [        / SQ5      5        U R                  UR                  S5        g )Nnoder  r   r   childrenr   r   ^.*$r   z#/definitions/node)r   rC  )r   r  )r   r  r  root)definitionsr   r  r  rh   ab)r  r
  r  z$.root)r
  r  rh   )	r  r
  r  r   r  r  rC  r	  r  z$.root.children.a)r
  r  rh   r  r  )r  r
  r  r   r  r  rC  r	  r  r   r  r  rC  r	  r  z$.root.children.a.children.ab)	r   r   rB   r)   r  r   r  r  r  )r0   r   r   r   r  r  r  s          r   test_recursive)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Gr3   c                   SSS.nSSSS.0n[         R                  " U5      nUR                  U5      n[        U5      u  pVU R	                  UR
                  [        S/5      5        U R	                  UR
                  [        S/5      5        U R	                  UR                  S	5        U R	                  UR                  S
5        U R	                  UR                  S5        U R	                  UR                  S5        g )Nr   r   r  r!  r   r_  r   r   r   r  r  r   r   	r   r   rB   r  r)   r  r   r  r   r0   r   r   r   r   r  r  s          r   test_additionalProperties4TestValidationErrorDetails.test_additionalPropertiesv  s     +(9*KL..v6	&&x0v&%.1%.1w/w/v.y1r3   c                   SSS.nSSS0SS0S.0n[         R                  " U5      nUR                  U5      n[        U5      u  pVU R	                  UR
                  [        S	/5      5        U R	                  UR
                  [        S
/5      5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  S5        g )NrJ   r   r  rC  r   r   r   r_  r   r   r  r  r  r  s          r   test_patternProperties1TestValidationErrorDetails.test_patternProperties  s    Q')!1~"
 ..v6	&&x0v&%.1%.1w/w/v.y1r3   c                   SS/n/ SSS.S.n[         R                  " U5      nUR                  U5      n[        U5      u  pVU R	                  UR
                  [        S/5      5        U R	                  UR
                  [        S/5      5        U R	                  UR                  S5        U R	                  UR                  S	5        U R	                  UR                  S
5        U R	                  UR                  S5        g )Nr   rJ   r   r_  r  r  r   r  $[1]r   r   r  r  s          r   test_additionalItems/TestValidationErrorDetails.test_additionalItems  s    1:(1a@

 ..v6	&&x0v&%*-%*-v.v.v.y1r3   c                   / SQn0 /SSS.S.n[         R                  " U5      nUR                  U5      n[        U5      u  pVU R	                  UR
                  [        S/5      5        U R	                  UR
                  [        S/5      5        U R	                  UR                  S5        U R	                  UR                  S	5        U R	                  UR                  S
5        U R	                  UR                  S5        g )N)r   r   rJ   r   r_  r  r  rJ   r   r  z$[2]r   r   r  r  s          r   test_additionalItems_with_items:TestValidationErrorDetails.test_additionalItems_with_items  s    $T(1a@

 ..v6	&&x0v&%*-%*-v.v.v.y1r3   c                   SS0nSSSS000n[         R                  " U5      nUR                  U5      u  nU R                  UR                  S5        U R                  UR
                  S5        U R                  UR                  [        / 5      5        U R                  UR                  S5        U R                  UR                  [        SS/5      5        g )Nr   r   propertyNamesr   r   z0'foo' should not be valid under {'const': 'foo'}r  
r   r  rB   r)   r   r   r  r   r  rI   )r0   r   r   r   errors        r   test_propertyNames-TestValidationErrorDetails.test_propertyNames  s    2;!EGU+;#<=..v6	&&x0%0MM>	
 	U2Y/#.**E?E2J,KLr3   c                   SS0SS0S.n[         R                  " U5      nUR                  S5      u  nU R                  UR                  S5        U R                  UR
                  S5        U R                  UR                  [        / 5      5        U R                  UR                  S5        U R                  UR                  [        SS/5      5        g )Nr   r      )ifthen13 was expectedr  r(  r!  r0   r   r   r"  s       r   test_if_then'TestValidationErrorDetails.test_if_then      B-bM

 ..v6	&&r*'2(9:U2Y/#.**E672C,DEr3   c                   SS0SS0S.n[         R                  " U5      nUR                  S5      u  nU R                  UR                  S5        U R                  UR
                  S5        U R                  UR                  [        / 5      5        U R                  UR                  S5        U R                  UR                  [        SS/5      5        g )	Nr   r   r&  )r'  elser  r)  r  r/  r!  r*  s       r   test_if_else'TestValidationErrorDetails.test_if_else  r-  r3   c                4   [         R                  " S5      nUR                  S5      u  nU R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  4SS S SS[        / 5      S45        g )NFr   zFalse schema does not allow 12r  )r   r  rB   r)   r   r   rH   r   r   rI   r  r   )r0   r   r"  s      r   test_boolean_schema_False4TestValidationErrorDetails.test_boolean_schema_False  s    ..u5	&&r*%%!! 1b		
r3   c                   SSSS00p![         R                  " SU0[         R                  " S0 X0S9S9nUR                  S	S
05      u  nU R	                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  4SSSS
[        S	/5      SS0[        SS/5      S45        g )NsomeRefr!  r   r   r   r}   storeresolverr   notAnIntegerz''notAnInteger' is not of type 'integer'r  )r   r  _RefResolverrB   r)   r   r   rH   r   r  r   rI   r  r   )r0   refr   r   r"  s        r   test_ref#TestValidationErrorDetails.test_ref  s    "869:M!NV..SM,,RC=I
	 &&~'>?%%##!!	 :ug#-v67		
r3   c                   SSS00 0 SS0/0n[         R                  " U5      nUR                  / SQ5      u  p4U R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  4SSSS[        S	/5      SS0[        / S
Q5      S45        U R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  4SSSS[        S/5      SS0[        / SQ5      S45        g )NrZ  r   r   r   rT   r^  r   rJ   r   )rZ  r   r   r  z"5 is greater than the maximum of 3r_  )rZ  rT   r   $[3]r   r   rB   r)   r   r   rH   r   r  r   rI   r  r   )r0   r   r   
type_error	min_errors        r   test_prefixItems+TestValidationErrorDetails.test_prefixItems+  sY   68"4b"y!n!MN33F;	 ) 5 56F G
""$$**##((!!&&$$	 ,qc
"01		
, 	!!##))""''  %%##	 5qc
A34		
r3   c                   SS00 /S.n[         R                  " U5      nUR                  / SQ5      u  p4U R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  4SSSS[        S/5      SS0[        SS/5      S	45        U R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  4S
SSS[        S/5      SS0[        SS/5      S45        g )Nr   r   rY  )r   r   r   rz  r  z2 is not of type 'string'r   rJ   r  r  z4 is not of type 'string'rz  rT   rA  rB  r0   r   r   r  r  s        r   r[  6TestValidationErrorDetails.test_prefixItems_with_items\  sC   h'4
 33F;	&&'BC

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

""  			 ,qc
"w'(		
r3   c                   SS0SS.n[         R                  " U5      nUR                  / SQ5      u  nU R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  4SSS/ SQ[        / 5      SS0SS.[        S/5      S	45        g
)zp
`contains` + `maxContains` produces only one error, even if there are
many more incorrectly matching elements.
r   r   r   r  )r   r   r   rz  r  r  r  r|  r.  r  NrB  r*  s       r   r  1TestValidationErrorDetails.test_contains_too_many  s    
  &x0C33F;	&&'JK%%##!!	 M3b	$h/Bzl#		
r3   c                   SS0SS.n[         R                  " U5      nUR                  / SQ5      u  nU R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  4SSS/ SQ[        / 5      SS0SS.[        S/5      S	45        g )
Nr   r   r   rt  )r   r   rz  rv  ru  r.  r  rB  r*  s       r   rw  0TestValidationErrorDetails.test_contains_too_few  s    %x0C33F;	&&}5%%##!!	? b	$h/Bzl#	
r3   c                   SS0SS.n[         R                  " U5      nUR                  SS/5      u  nU R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  4SSSS0SS/[        / 5      SS0SS.[        S/5      S45        g )	Nr   r   r   rt  rz  z7[2, 4] does not contain items matching the given schemar.  r  rB  r*  s       r   test_contains_none-TestValidationErrorDetails.test_contains_none  s    %x0C33F;	&&1v.%%##!!	 J"Ab	$h/Bzl#		
r3   c                   SSS/00SSS/S.0S.n[         R                  " U5      nUR                  S0 05      u  p4U R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  4	S	SS/0 [        S/5      SS/0[        / S
Q5      [        / S
Q5      S4	5        U R                  UR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  4	SSS/0 [        S/5      SS/S.[        / S
Q5      [        / S
Q5      S4	5        g )Nr   r  r   apropz#/$defs/foor  )r   r  )r   r  z'bar' is a required property)r  rR  r  z$.apropz'baz' is a required property)r   r   rB   r)   r   r   rH   r   r  r   rI   r  r  r   rH  s        r   test_ref_sibling+TestValidationErrorDetails.test_ref_sibling  s   j5'23)!&
 33F;	&&}5

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

""  		''
 /wi &UG<9:9:
	
r3   r   N)r^   r   r_   r   r  r  r  r  r  r  r  r  r  r#  r+  r0  r3  r>  rE  r[  r  rw  rO  rS  r   r   r3   r   r  r    st    C-JK%Z%/N;/zcHJ2"2,2(2(M FF
2
>/
b2
h
>
<
6<
r3   r  c                  8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
MetaSchemaTestsMixini'  c                    U R                  [        R                  5         U R                  R	                  SS05        S S S 5        g ! , (       d  f       g = f)Nr  r   r   r   r   r.   r   r/   s    r   test_invalid_properties,MetaSchemaTestsMixin.test_invalid_properties)  s9    z556NN''r(:; 766   A
Ac                    U R                  [        R                  5         U R                  R	                  SS05        S S S 5        g ! , (       d  f       g = f)NrQ  1rX  r/   s    r   test_minItems_invalid_string1MetaSchemaTestsMixin.test_minItems_invalid_string-  s9    z556NN''S(9: 766r[  c                H   U R                   [        R                  [        R                  1;   aF  U R	                  [
        R                  5         U R                   R                  S/ 05        SSS5        gU R                   R                  S/ 05        g! , (       d  f       g= f)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_arrays2MetaSchemaTestsMixin.test_enum_allows_empty_arrays2  s|     >>&&&&
 
 "":#9#9:++VRL9 ;: NN''5 ;:s   B
B!c                P   U R                   [        R                  [        R                  1;   aH  U R	                  [
        R                  5         U R                   R                  SSS/05        SSS5        gU R                   R                  SSS/05        g! , (       d  f       g= f)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   Nra  r/   s    r   !test_enum_allows_non_unique_items6MetaSchemaTestsMixin.test_enum_allows_non_unique_itemsC  s     >>&&&&
 
 "":#9#9:++Vb"X,>? ;: NN''"b(:; ;:s    B
B%c                    U R                  [        R                  5         U R                  R	                  SS05        S S S 5        g ! , (       d  f       g = f)Nrm  
*notaregexrX  r/   s    r   test_schema_with_invalid_regex3MetaSchemaTestsMixin.test_schema_with_invalid_regexT  s9    z556NN''L(AB 766r[  c                <    U R                   R                  SS0S S9  g )Nrm  rh  r;  )r.   r   r/   s    r   >test_schema_with_invalid_regex_with_disabled_format_validationSMetaSchemaTestsMixin.test_schema_with_invalid_regex_with_disabled_format_validationX  s$    ##% 	$ 	
r3   r   N)r^   r   r_   r   rY  r^  rb  re  ri  rm  r   r   r3   r   rV  rV  '  s!    <;
6"<"C
r3   rV  c                      \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rSrg)ValidatorTestMixini_  c                b    U R                  U R                  0 5      [        R                  5        g r5   )assertIsInstancer.   r   r/   s    r   )test_it_implements_the_validator_protocol<ValidatorTestMixin.test_it_implements_the_validator_protocol`  s!    dnnR0)2E2EFr3   c                ~    U R                   u  pU R                  U R                  U5      R                  U5      5        g r5   )validr   r.   r   r0   r   r   s      r   test_valid_instances_are_valid1ValidatorTestMixin.test_valid_instances_are_validc  s.    ::v.77ABr3   c                ~    U R                   u  pU R                  U R                  U5      R                  U5      5        g r5   )invalidr  r.   r   rw  s      r   $test_invalid_instances_are_not_valid7ValidatorTestMixin.test_invalid_instances_are_not_validg  s0    <</88BCr3   c                t    U R                  [        5       [        5       05      R                  [        5       S9  g )N)r   )r.   r   r   r/   s    r   (test_non_existent_properties_are_ignored;ValidatorTestMixin.test_non_existent_properties_are_ignoredk  s'    &(+,55vx5Hr3   c                0   SS0[        5       p!U R                  UUS9nUR                  SS0U R                  R                  S9nU R                  SS0U R                  R                  UR                  S9nU R                  XE5        U R                  XC5        g )Nr   r   rl  r   )r   r;  )r;  	_resolver)r   r.   evolveFORMAT_CHECKERr  r)   assertNotEqual)r0   r   r;  rv   r   expecteds         r   test_evolveValidatorTestMixin.test_evolven  s    "()!4mo>>) " 
 ooH%>>88  

 >>X>>88mm " 
 	'C*r3   c                ~   U R                  [        5         [         " S SU R                  5      5       nSSS5        W" 0 SS9nU R	                  UR
                  / SQ5        UR                  SS0S	9nU R	                  UR
                  / SQ5        U R	                  UR                  S5        g! , (       d  f       N= f)
aB  
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                  .    \ rS rSr\" S S9r\" SS9rSrg):ValidatorTestMixin.test_evolve_with_subclass.<locals>.OhNoi  c                 
    / SQ$ )Nr  r   r   r3   r   r   CValidatorTestMixin.test_evolve_with_subclass.<locals>.OhNo.<lambda>  s    Ir3   )factoryr   defaultr   N)r^   r   r_   r   r   r   _barr   r   r3   r   OhNor    s    $56R(r3   r  Nr   )r   r  r   r   r   )assertWarnsDeprecationWarningr   r.   r)   r   r  r  )r0   r  r   r   s       r   test_evolve_with_subclass,ValidatorTestMixin.test_evolve_with_subclass  s     01)t~~ ) ) 2 $		2vy&9:),2& 21s   B..
B<c                d    U R                  U R                  0 5      R                  SS5      5        g )Nr   r   )r   r.   r   r/   s    r   #test_is_type_is_true_for_valid_type6ValidatorTestMixin.test_is_type_is_true_for_valid_type  s$    r*225(CDr3   c                d    U R                  U R                  0 5      R                  SS5      5        g )Nr   r   r  r.   r   r/   s    r   &test_is_type_is_false_for_invalid_type9ValidatorTestMixin.test_is_type_is_false_for_invalid_type  s&    +33E7CDr3   c                    U R                  U R                  0 5      R                  SS5      5        U R                  U R                  0 5      R                  SS5      5        g )NTr   r   r  r/   s    r   ,test_is_type_evades_bool_inheriting_from_int?ValidatorTestMixin.test_is_type_evades_bool_inheriting_from_int  sJ    +33D)DE+33D(CDr3   c                   SSS00n[         R                  " U R                  U R                  R                  R	                  SS 5      S9nU" U5      nUR                  SS[        S5      [        S5      -  /5        S	0 / S
S /nU R                  UR                  U5       Vs/ s H  oUR                  PM     snU5        g s  snf )Nr  r   r   c                p    [        U[        [        [        45      =(       a    [        U[        5      (       + $ r5   )
isinstanceintfloatr   boolr=  r4  s     r   r   GValidatorTestMixin.test_it_can_validate_with_decimals.<locals>.<lambda>  s,    zC0( (2$UD11(2r3   r'   rJ   g?r  r   T)
r   r   r.   r8   redefiner   r   r)   rB   r   )r0   r   r.   r   r{  r"  s         r   "test_it_can_validate_with_decimals5ValidatorTestMixin.test_it_can_validate_with_decimals  s    FH-.%%NN44==2
	 f%	AsGAJ$;<="b$-)2)>)>w)GH)G^^)GH	
Hs   !B?c                Z    U R                  SS0[        5       S9nUR                  S5        g )Nr9  carrotrl  bugs)r.   r   r   r0   r   s     r   7test_it_returns_true_for_formats_it_does_not_know_aboutJValidatorTestMixin.test_it_returns_true_for_formats_it_does_not_know_about  s1    NNx  # 
	 	6"r3   c                \    U R                  0 5      nU R                  UR                  5        g r5   )r.   r  r;  r  s     r   ,test_it_does_not_validate_formats_by_default?ValidatorTestMixin.test_it_does_not_validate_formats_by_default  s$    NN2&	)223r3   c                  ^ ^ [        5       n[        S5      mUR                  S[        S9UU 4S j5       nT R                  SS0US9nUR	                  S5        T R                  [        R                  5       nUR	                  S5        S S S 5        T R                  WR                  R                  T5        g ! , (       d  f       N5= f)	NzBad!r   )raisesc                N   > U S:X  a  gU S:X  a  TeTR                  SU  S35        g )NgoodTbadzWhat is z? [Baby Don't Hurt Me])r    )r7  r  r0   s    r   checkTValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provided.<locals>.check  s/    %			HUG+ABCr3   r9  rl  r  r  )r   
ValueErrorr<  r.   r   r   r   r   r  	exceptioncause)r0   r=  r  r   cmr  s   `    @r   2test_it_validates_formats_if_a_checker_is_providedEValidatorTestMixin.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   8B99
Cc                    [        5       nSU/0n[        R                  " U R                  U R                  R                  R                  US 5      S9nU" U5      R                  S5        g )Nr   c                "    [        U[        5      $ r5   r  r  r  s     r   r   @ValidatorTestMixin.test_non_string_custom_type.<locals>.<lambda>  s    z%'=r3   r  r  )r   r   r   r.   r8   r  r   )r0   non_string_typer   Crazys       r   test_non_string_custom_type.ValidatorTestMixin.test_non_string_custom_type  s_     (?+,!!NN44===
 	fr"r3   c                z   [         R                  " U R                  U R                  R                  R	                  SS 5      S9nU R                  [        R                  5       nU" SS05      R                  S5        SSS5        U R                  S[        WR                  5      5        g! , (       d  f       N4= f)	zP
A tuple instance properly formats validation errors for uniqueItems.

See #224
r   c                "    [        U[        5      $ r5   )r  tupler  s     r   r   NValidatorTestMixin.test_it_properly_formats_tuples_in_errors.<locals>.<lambda>  s    z%'?r3   r  uniqueItemsT)rJ   rJ   Nz(1, 1) has non-unique elements)r   r   r.   r8   r  r   r   r   r   r   strr  )r0   TupleValidatorr  s      r   )test_it_properly_formats_tuples_in_errors<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,,
B:c                  ^ SSS.n[        SS5      m[        R                  " U R                  U R                  R                  R                  S U4S jS.5      S	9nU" U5      n[        / S
Q5      [        S/S//5      [        S/5      [        S/5      /[        S/5      /[        S/5      //[        S/5      ////[        S/5      /////[        [        S/5      /5      [        [        S/5      /5      /T" SS5      T" SS5      /T" S[        S/5      /5      T" S[        S/5      /5      /T" ST" S[        S/5      5      /5      T" ST" S[        S/5      5      /5      /[        [        [        S/5      5      5      [        [        [        S/5      5      5      //
nU H  nUR                  U5        M     [        / SQ5      [        S/S//5      [        S/5      [        S/5      /[        S/5      /[        S/5      //[        S/5      ////[        S/5      /////[        [        S/5      /5      [        [        S/5      /5      /T" SS5      T" SS5      /T" S[        S/5      /5      T" S[        S/5      /5      /T" ST" S[        S/5      5      /5      T" ST" S[        S/5      5      /5      /[        [        [        S/5      5      5      [        [        [        S/5      5      5      //
nU H<  nU R                  [        R                  5         UR                  U5        SSS5        M>     g! , (       d  f       MP  = f)z?
Allow array to validate against another defined sequence type
r   T)r   r  	MyMappingza, bc                .    [        U[        [        45      $ r5   )r  rA   r   r  s     r   r   BValidatorTestMixin.test_check_redefined_sequence.<locals>.<lambda>  s    Je}5r3   c                (   > [        U[        T45      $ r5   )r  r+   )r=  r4  r  s     r   r   r    s    Zi06r3   )r   r   r  )rh   Nr]  r}   TFr   rh   )rh   r  rh   N)r   r   r   r.   r8   redefine_manyr   r   r   r   r   )r0   r   r.   r   valid_instancesr   invalid_instancesr  s          @r   test_check_redefined_sequence0ValidatorTestMixin.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                    U R                  [        5         U R                  0 5      R                  nS S S 5        U R	                  W[
        R                  5        g ! , (       d  f       N/= fr5   )r  r  r.   r:  rr  r   r<  )r0   r:  s     r   .test_it_creates_a_ref_resolver_if_not_providedAValidatorTestMixin.test_it_creates_a_ref_resolver_if_not_provided9  sI    01~~b)22H 2h
(?(?@ 21s   A
A)c                    SSS0p![         R                  " S0 X0S9nU R                  SU0US9nU R                  [        R
                  5         UR                  S 5        S S S 5        g ! , (       d  f       g = f)NsomeCoolRefr   r   r}   r7  r   r9  )r   r<  r.   r   r   r   r   r0   r=  r   r:  r   s        r   /test_it_upconverts_from_deprecated_RefResolversBValidatorTestMixin.test_it_upconverts_from_deprecated_RefResolvers>  sh    #fi%8V**2r#GNNFC=8ND	z99:t$ ;::s   A))
A7c                   ^   " U 4S jS5      nU" 5       nSS0nT R                  [        R                  5         T R                  X2S9R	                  S5        SSS5        g! , (       d  f       g= f)zJ
Legacy RefResolvers support only the context manager form of
resolution.
c                  ,   > \ rS rSr\U 4S j5       rSrg)nValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolvers.<locals>.LegacyRefResolveriL  c              3  >   >#    TR                  US5        SS0v   g 7f)Nthe refr   r   r)   )thisr=  r0   s     r   	resolvingxValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolvers.<locals>.LegacyRefResolver.resolvingM  s!       i0y))s   r   N)r^   r   r_   r   r   r  r   r/   s   r   LegacyRefResolverr  L  s    * *r3   r  r   r  r9  N)r   r   r   r.   r   )r0   r  r:  r   s   `   r   @test_it_upconverts_from_yet_older_deprecated_legacy_RefResolversSValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolversF  sZ    	* 	* %&)$z99:NN6N5>>tD ;::s   A!!
A/r   N)r^   r   r_   r   rs  rx  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r3   r   rp  rp  _  sm    GCDI+('.EEE
*#4/0
#J"@-DA
%Er3   rp  c                  0    \ rS rSrSrS rS rS rS rSr	g)	AntiDraft6LeakMixiniY  zF
Make sure functionality from draft 6 doesn't leak backwards in time.
c                    U R                  [        R                  5       nU R                  R	                  S5        S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)NTzTrue is not of typer   r   r   r.   r   r   r  r  r0   r  s     r   test_True_is_not_a_schema-AntiDraft6LeakMixin.test_True_is_not_a_schema^  sP    z556!NN''- 7+S-=> 76   A**
A8c                    U R                  [        R                  5       nU R                  R	                  S5        S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)NFzFalse is not of typer  r  s     r   test_False_is_not_a_schema.AntiDraft6LeakMixin.test_False_is_not_a_schemac  sP    z556!NN''. 7,c!++.>? 76r  c                    U R                  [        5       nU R                  S5      R                  S5        S S S 5        U R	                  WR
                  [        R                  5        g ! , (       d  f       N9= f)NTr   r   	Exceptionr.   r   assertNotIsInstancer  r   r   r  s     r   5test_True_is_not_a_schema_even_if_you_forget_to_checkIAntiDraft6LeakMixin.test_True_is_not_a_schema_even_if_you_forget_to_checkh  sQ    y)QNN4 ))"- *  j.H.HI *)   !A**
A8c                    U R                  [        5       nU R                  S5      R                  S5        S S S 5        U R	                  WR
                  [        R                  5        g ! , (       d  f       N9= f)NFr   r  r  s     r   6test_False_is_not_a_schema_even_if_you_forget_to_checkJAntiDraft6LeakMixin.test_False_is_not_a_schema_even_if_you_forget_to_checkm  sQ    y)QNN5!**2. *  j.H.HI *)r  r   N)
r^   r   r_   r   __doc__r  r  r  r  r   r   r3   r   r  r  Y  s    ?
@
J
Jr3   r  c                  d    \ rS rSr% \R
                  r0 0 4rS\S'   SS0S4r	S r
S rS	 rS
 rSrg)TestDraft3Validatoris  tuple[dict, dict]rv  r   r   r   c                \    U R                  SS05      nUR                  [        5       5        g Nr   any)r.   r   r   r  s     r   #test_any_type_is_valid_for_type_any7TestDraft3Validator.test_any_type_is_valid_for_type_anyx  s$    NNFE?3	68$r3   c                V   [         R                  " U R                  U R                  R                  R	                  SS 5      S9nU" SS05      nUR                  S5        U R                  [        R                  5         UR                  S5        SSS5        g! , (       d  f       g= f)z
Sigh, because why not.
r  c                "    [        U[        5      $ r5   r  r  s     r   r   BTestDraft3Validator.test_any_type_is_redefinable.<locals>.<lambda>  s    j.Dr3   r  r   r   r   N)	r   r   r.   r8   r  r   r   r   r   )r0   r  r   s      r   test_any_type_is_redefinable0TestDraft3Validator.test_any_type_is_redefinable|  s     !!NN44==D
 65/*	2z99:u% ;::s   ?B
B(c                v    U R                  U R                  SS05      R                  [        5       5      5        g r  )r   r.   r   r   r/   s    r   !test_is_type_is_true_for_any_type5TestDraft3Validator.test_is_type_is_true_for_any_type  s(    7@@JKr3   c                    U R                  U R                  0 5      R                  SS5      5        U R                  U R                  SS05      R                  S5      5        g )NTr   r   r  )r   r.   r   r   r/   s    r   6test_is_type_does_not_evade_bool_if_it_is_being_testedJTestDraft3Validator.test_is_type_does_not_evade_bool_if_it_is_being_tested  sH    r*224CD7@@FGr3   r   N)r^   r   r_   r   r   r   r.   rv  __annotations__r{  r  r  r  r  r   r   r3   r   r
  r
  s  sA    **I "BxE'y!5(G%&LHr3   r
  c                  L    \ rS rSr% \R
                  r0 0 4rS\S'   SS0S4r	Sr
g)	TestDraft4Validatori  r  rv  r   r   r   r   N)r^   r   r_   r   r   r   r.   rv  r  r{  r   r   r3   r   r  r    +    **I "BxE'y!5(Gr3   r  c                  L    \ rS rSr% \R
                  r0 0 4rS\S'   SS0S4r	Sr
g)	TestDraft6Validatori  r  rv  r   r   r   r   N)r^   r   r_   r   r   r/  r.   rv  r  r{  r   r   r3   r   r!  r!    r  r3   r!  c                  L    \ rS rSr% \R
                  r0 0 4rS\S'   SS0S4r	Sr
g)	TestDraft7Validatori  r  rv  r   r   r   r   N)r^   r   r_   r   r   r  r.   rv  r  r{  r   r   r3   r   r#  r#    r  r3   r#  c                  L    \ rS rSr% \R
                  r0 0 4rS\S'   SS0S4r	Sr
g)	TestDraft201909Validatori  r  rv  r   r   r   r   N)r^   r   r_   r   r   Draft201909Validatorr.   rv  r  r{  r   r   r3   r   r%  r%    +    //I "BxE'y!5(Gr3   r%  c                  L    \ rS rSr% \R
                  r0 0 4rS\S'   SS0S4r	Sr
g)	TestDraft202012Validatori  r  rv  r   r   r   r   N)r^   r   r_   r   r   r   r.   rv  r  r{  r   r   r3   r   r)  r)    r'  r3   r)  c                      \ rS rSrSrS rSrg)TestLatestValidatori  zI
These really apply to multiple versions but are easiest to test on one.
c                    SnSU0n[         R                  " S0 US0S9n[         R                  " X#S9nU R                  [        R
                  5         UR                  S 5        S S S 5        g ! , (       d  f       g = f)Nr  r   r}   Fr7  r9  )r   r<  r   r   r   r   r   r  s        r   2test_ref_resolvers_may_have_boolean_schemas_storedFTestLatestValidator.test_ref_resolvers_may_have_boolean_schemas_stored  sf    #**2r#uF..vI	z99:t$ ;::s   A--
A;r   N)r^   r   r_   r   r  r-  r   r   r3   r   r+  r+    s    %r3   r+  c                  n    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rSrg)TestValidatorFori  c                    SS0nU R                  [        R                  " U5      [        R                  5        SS0nU R                  [        R                  " U5      [        R                  5        g )Nr   &http://json-schema.org/draft-03/schema'http://json-schema.org/draft-03/schema#)r  r   validator_forr   r<   s     r   test_draft_3TestValidatorFor.test_draft_3  `    EF$$V,&&	

 FG$$V,&&	
r3   c                    SS0nU R                  [        R                  " U5      [        R                  5        SS0nU R                  [        R                  " U5      [        R                  5        g )Nr   &http://json-schema.org/draft-04/schema'http://json-schema.org/draft-04/schema#)r  r   r4  r   r<   s     r   test_draft_4TestValidatorFor.test_draft_4  r7  r3   c                    SS0nU R                  [        R                  " U5      [        R                  5        SS0nU R                  [        R                  " U5      [        R                  5        g )Nr   &http://json-schema.org/draft-06/schema'http://json-schema.org/draft-06/schema#)r  r   r4  r/  r<   s     r   test_draft_6TestValidatorFor.test_draft_6  r7  r3   c                    SS0nU R                  [        R                  " U5      [        R                  5        SS0nU R                  [        R                  " U5      [        R                  5        g )Nr   &http://json-schema.org/draft-07/schema'http://json-schema.org/draft-07/schema#)r  r   r4  r  r<   s     r   test_draft_7TestValidatorFor.test_draft_7  r7  r3   c                    SS0nU R                  [        R                  " U5      [        R                  5        SS0nU R                  [        R                  " U5      [        R                  5        g )Nr   z,https://json-schema.org/draft/2019-09/schemaz-https://json-schema.org/draft/2019-09/schema#)r  r   r4  r&  r<   s     r   test_draft_201909"TestValidatorFor.test_draft_201909  `    KL$$V,++	

 LM$$V,++	
r3   c                    SS0nU R                  [        R                  " U5      [        R                  5        SS0nU R                  [        R                  " U5      [        R                  5        g )Nr   ,https://json-schema.org/draft/2020-12/schema-https://json-schema.org/draft/2020-12/schema#)r  r   r4  r   r<   s     r   test_draft_202012"TestValidatorFor.test_draft_202012  rJ  r3   c                l    U R                  [        R                  " S5      [        R                  5        g )NTr  r   r4  r   r/   s    r   	test_TrueTestValidatorFor.test_True  s%    $$T*&&	
r3   c                l    U R                  [        R                  " S5      [        R                  5        g r6  rQ  r/   s    r   
test_FalseTestValidatorFor.test_False  s%    $$U+&&	
r3   c                    [         R                  " SS0SS S9nSS0nU R                  [         R                  " U5      U5        g )Nru   rz   12c                &    U R                  SS5      $ r|   r~   r   s    r   r   8TestValidatorFor.test_custom_validator.<locals>.<lambda>  r   r3   r   r   r   r-   r  r4  r0   r.   r   s      r   test_custom_validator&TestValidatorFor.test_custom_validator  sK    %%/0+
	
 -.$$V,	
r3   c                    [         R                  " SS0SS9nSS0nU R                  [         R                  " U5      U5        g )Nr%   r   13rZ   r   r[  r\  s      r   test_custom_validator_draft6-TestValidatorFor.test_custom_validator_draft6'  sH    %% 12
	 ./$$V,	
r3   c                l    U R                  [        R                  " 0 5      [        R                  5        g r5   rQ  r/   s    r   %test_validator_for_jsonschema_default6TestValidatorFor.test_validator_for_jsonschema_default2  s!    j..r2J4N4NOr3   c                N    U R                  [        R                  " 0 S S9S 5        g )Nr  )r  r   r4  r/   s    r   !test_validator_for_custom_default2TestValidatorFor.test_validator_for_custom_default5  s    j..r4@$Gr3   c                   U R                  [        5       n[        R                  " SS0S9  S S S 5        U R	                  WR
                  [        5        U R	                  [        UR                  5      S5        g ! , (       d  f       NT= f)Nr   unknownSchemar  zThe metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.)	r  r  r   r4  r)   filename__file__r  warning)r0   r  s     r   1test_warns_if_meta_schema_specified_was_not_foundBTestValidatorFor.test_warns_if_meta_schema_specified_was_not_found8  sh    01R$$Y,HI 2 	h/

O&	
	 21s   A;;
B	c                    [         R                  " SS9 n[         R                  " S5        [        R                  " 0 0 S9  S S S 5        U R                  W5        g ! , (       d  f       N = f)NTrecordalways)r   r  )warningscatch_warningssimplefilterr   r4  r  )r0   ws     r   0test_does_not_warn_if_meta_schema_is_unspecifiedATestValidatorFor.test_does_not_warn_if_meta_schema_is_unspecifiedD  sN    $$D1Q!!(+$$B; 2 	 21s   ,A
A)c                j    SS0[        5       p!U R                  [        R                  " X5      U5        g )Nr   zmailto:foo@example.com)r   r  r   r4  )r0   r   r  s      r   -test_validator_for_custom_default_with_schema>TestValidatorFor.test_validator_for_custom_default_with_schemaJ  s*    $&>?j..v?Ir3   r   N)r^   r   r_   r   r5  r;  r@  rE  rH  rN  rR  rU  r]  ra  rd  rg  rn  rx  r{  r   r   r3   r   r0  r0    sP    









	
PH

Jr3   r0  c                  P    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rSrg)TestValidateiO  c                    / n[         R                  R                  USUR                  5         [        R
                  " 0 U5        S S S 5        U R                  X1/5        g ! , (       d  f       N!= f)Nr   )r   patchr   appendr   r   r)   )r0   r   r.   results       r   
assertUsesTestValidate.assertUsesP  sQ    ZZy.&--HF+ I* IHs   A!!
A/c                    U R                  SS0[        R                  S9  U R                  SS0[        R                  S9  g )Nr   r3  r   r.   r2  )r  r   r   r/   s    r   test_draft3_validator_is_chosen,TestValidate.test_draft3_validator_is_chosenV  J    HI 00 	 	

 	GH 00 	 	
r3   c                    U R                  SS0[        R                  S9  U R                  SS0[        R                  S9  g )Nr   r:  r  r9  )r  r   r   r/   s    r   test_draft4_validator_is_chosen,TestValidate.test_draft4_validator_is_chosena  r  r3   c                    U R                  SS0[        R                  S9  U R                  SS0[        R                  S9  g )Nr   r?  r  r>  )r  r   r/  r/   s    r   test_draft6_validator_is_chosen,TestValidate.test_draft6_validator_is_chosenl  r  r3   c                    U R                  SS0[        R                  S9  U R                  SS0[        R                  S9  g )Nr   rD  r  rC  )r  r   r  r/   s    r   test_draft7_validator_is_chosen,TestValidate.test_draft7_validator_is_chosenw  r  r3   c                    U R                  SS0[        R                  S9  U R                  SS0[        R                  S9  g )Nr   rM  r  rL  r  r   r   r/   s    r   $test_draft202012_validator_is_chosen1TestValidate.test_draft202012_validator_is_chosen  sR    J !55	 	 	
 	I !55	 	 	
r3   c                @    U R                  0 [        R                  S9  g )Nr  r  r/   s    r   )test_draft202012_validator_is_the_default6TestValidate.test_draft202012_validator_is_the_default  s    rZ-L-LMr3   c                    U R                  [        R                  5       n[        R                  " SSS05        S S S 5        U R                  [        WR                  5      S5        g ! , (       d  f       N4= f)Nr   r   r   z1(?s)Failed validating '.*' in schema.*On instance)r   r   r   r   r   assertRegexr  r  r  s     r   test_validation_error_message*TestValidate.test_validation_error_message  sX    z99:aVX$67 ;?	
 ;:   A((
A6c                    U R                  [        R                  5       n[        R                  " SSS05        S S S 5        U R                  [        WR                  5      S5        g ! , (       d  f       N4= f)Nr   r   z3(?s)Failed validating '.*' in metaschema.*On schema)r   r   r   r   r   r  r  r  r  s     r   test_schema_error_message&TestValidate.test_schema_error_message  sW    z556!VRL1 7A	
 76r  c                   SSSS.SS0/0nU R                  [        R                  5       n[        R                  " SU5        S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)	Nr  r   r  r  r   r   r   z!12 is less than the minimum of 20)r   r   r   r   r   r   r  r  )r0   r   r  s      r   test_it_uses_best_match$TestValidate.test_it_uses_best_match  so    !b1!
 z99:aF+ ;93q{{;KL ;:s   A11
A?r   N)r^   r   r_   r   r  r  r  r  r  r  r  r  r  r  r   r   r3   r   r~  r~  O  s6    +	
	
	
	

N

	Mr3   r~  c                      \ rS rSrSrS rSrg)TestThreadingi  a  
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                   ^ / mU4S jnU" 5         SSK Jn  U" US9nUR                  5         UR                  5         U R	                  UR                  5       T4S/ 45        g )Nc                    >  [         R                  " SSS9  g !   T R                  [        R                  " 5       5         g = f)Nr   Tr   )r   r   r  sysexc_info)faileds   r   r   FTestThreading.test_validation_across_a_second_thread.<locals>.validate  s1    .##R=.clln-s	    &Ar   )Thread)targetF)	threadingr  startjoinr)   is_alive)r0   r   r  threadr  s       @r   &test_validation_across_a_second_thread4TestThreading.test_validation_across_a_second_thread  sS    	. 	
$x(&//+V4ubkBr3   r   N)r^   r   r_   r   r  r  r   r   r3   r   r  r    s    
Cr3   r  c                       \ rS rSrS rS rSrg)TestReferencingi  c                    S n[         R                  " US9nSS0n[        R                  " X2S9nU R	                  UR                  S5      UR                  S5      4S5        g )	Nc                2    [         R                  " SS05      $ )Nr   r   )r   create_resource)uris    r   retrieve=TestReferencing.test_registry_with_retrieve.<locals>.retrieve  s    ..	/BCCr3   )r  r   https://example.com/registryr   r   )TF)referencingRegistryr   r   r)   r   )r0   r  r  r   r   s        r   test_registry_with_retrieve+TestReferencing.test_registry_with_retrieve  sd    	D '':0133FN	#Y%7%7%>?	
r3   c                   [         R                  " 5       nSS0n[        R                  " X!S9n[        R
                  " SS9 n[        R                  " S5        U R                  [         R                  R                  5         UR                  S5        S S S 5        S S S 5        U R                  W5        g ! , (       d  f       N(= f! , (       d  f       N1= f)Nr   r  r  Trq  rs  r   )r  r  r   r   rt  ru  rv  r   r   Unresolvabler   r  )r0   r  r   r   rw  s        r   ;test_custom_registries_do_not_autoretrieve_remote_resourcesKTestReferencing.test_custom_registries_do_not_autoretrieve_remote_resources  s    '')0133FN	$$D1Q!!(+"";#9#9#F#FG""2& H 2 	 HG 21s%   A CB6C6
C	 C
Cr   N)r^   r   r_   r   r  r  r   r   r3   r   r  r    s    
	r3   r  c                      \ rS rSrSrSrSS0rS rS rS r	S	 r
S
 rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)TestRefResolveri  r}   zfoo://storedstoredr   c                    0 U l         U R                  U R                  0U l        [        R
                  " U R                  U R                   U R                  5      U l        g r5   )referrer
stored_uristored_schemar8  r   r<  base_urir:  r/   s    r   r1   TestRefResolver.setUp  sD    oot'9'9:
"//MM4==$**
r3   c                   [         R                  R                  S   n[        R                  R                  U R                  S5       nU R                  R                  U5       n S S S 5        S S S 5        U R                  W[         R                  R                  5        U R                  WR                  5        g ! , (       d  f       N\= f! , (       d  f       Ne= f)Nru   resolve_remote)r   r   r7   r   r  r   r:  r  r)   r  called)r0   r=  patchedresolveds       r   6test_it_does_not_retrieve_schema_urls_from_the_networkFTestRefResolver.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                    SnS[        5       0U R                  S'   U R                  R                  U5       nU R	                  X R                  S   S   5        S S S 5        g ! , (       d  f       g = f)Nz#/properties/foor   r  )r   r  r:  r  r)   )r0   r=  r  s      r   test_it_resolves_local_refs+TestRefResolver.test_it_resolves_local_refs  sX     ',fh&7l#]]$$S)XX}}\'B5'IJ *))s   "A""
A0c                L   SSS0S.n[         R                  R                  US S9nUR                  S5       nU R	                  X1S   5        S S S 5        UR                  S	5       nU R	                  X1S   5        S S S 5        g ! , (       d  f       N== f! , (       d  f       g = f)
Nzhttp://bar/schema#r   r   )ru   rh   c                &    U R                  SS5      $ r|   r~   r  s    r   r   ETestRefResolver.test_it_resolves_local_refs_with_id.<locals>.<lambda>	      D"!5r3   r   z#/arh   zhttp://bar/schema#/a)r   r<  from_schemar  r)   r0   r   r:  r  s       r   #test_it_resolves_local_refs_with_id3TestRefResolver.test_it_resolves_local_refs_with_id	  s    ,E5>B**665 7 
 &(Xc{3 ' 678Xc{3 87 '&77s   B&B
B
B#c                |   U R                   R                  U R                  5       nU R                  XR                  5        S S S 5        SS0U R                   R
                  S'   U R                   R                  S5       nU R                  US5        S S S 5        g ! , (       d  f       N`= f! , (       d  f       g = f)Nr   r   
cached_refzcached_ref#/foo)r:  r  r  r  r  r8  r)   )r0   r  s     r   test_it_retrieves_stored_refs-TestRefResolver.test_it_retrieves_stored_refs	  s    ]]$$T__5MM($6$67 6 .3BKL)]]$$%678Xr* 87	 65 87s   B B-
B*-
B;c                z   SnSS0nS[         R                  ;   a<  U R                  [         R                  R                  S[         R                  S   5        [	        SU05      [         R                  S'   U R
                  R                  U5       nU R                  US5        S S S 5        g ! , (       d  f       g = f)Nhttp://bar#bazr  r   requests
http://bar)r  modulesr(   __setitem__ReallyFakeRequestsr:  r  r)   )r0   r=  r   r  s       r   ,test_it_retrieves_unstored_refs_via_requests<TestRefResolver.test_it_retrieves_unstored_refs_via_requests	  s    $OO''S[[5L #5lF5K"LJ]]$$S)XXr* *))s   B,,
B:c                  ^ ^ SnSS0mS[         R                  ;   a<  T R                  [         R                  R                  S[         R                  S   5        S [         R                  S'   [        UU 4S j5       nT R                  [
        [        S[        R                  5        U[        l        T R                  R                  U5       n S S S 5        T R                  WS5        g ! , (       d  f       N!= f)Nr  r  r   r  c              3     >#    TR                  U S5        [        [        R                  " T5      R	                  S5      5      v   g 7f)Nr  utf8)r)   r   jsondumpsencode)urlr   r0   s    r   fake_urlopenQTestRefResolver.test_it_retrieves_unstored_refs_via_urlopen.<locals>.fake_urlopen.	  s5     S,/$**V,33F;<<s   AAurlopen)r  r  r(   r  r   setattrr   r  r:  r  r)   )r0   r=  r  r  r   s   `   @r   +test_it_retrieves_unstored_refs_via_urlopen;TestRefResolver.test_it_retrieves_unstored_refs_via_urlopen$	  s    $OO''S[[5L #'J		= 
	= 	Y
8J8JK)
]]$$S)X *2& *)s   C))
C7c                   [         R                  " SSS9 nU R                  [        R                  UR
                  5        [        R                  " SS0U5        S S S 5        S[        WR
                  5       S3nU R                  R                  U5       nU R                  US5        S S S 5        g ! , (       d  f       N^= f! , (       d  f       g = f)NFwt)deletemoder   r   zfile://z#foo)tempfileNamedTemporaryFiler(   osremover   r  dumpr   r:  r  r)   )r0   tempfr=  r  s       r   (test_it_retrieves_local_refs_via_urlopen8TestRefResolver.test_it_retrieves_local_refs_via_urlopen:	  s    ((DAUOOBIIuzz2IIuene, B UZZ016]]$$S)XXu- *) BA
 *)s   AB2C2
C 
Cc                   SS0n[         R                  R                  US S9nU R                  UR                  S5        U R                  UR
                  S5        UR                  S5       nU R                  X15        S S S 5        UR                  S5       nU R                  X15        S S S 5        UR                  S5       nU R                  X15        S S S 5        UR                  S5       nU R                  X15        S S S 5        g ! , (       d  f       N= f! , (       d  f       Nv= f! , (       d  f       N\= f! , (       d  f       g = f)Nru   r   c                &    U R                  SS5      $ r|   r~   r  s    r   r   PTestRefResolver.test_it_can_construct_a_base_uri_from_a_schema.<locals>.<lambda>G	  r  r3   r  r}   #zfoo#r   r<  r  r)   r  resolution_scoper  r  s       r   .test_it_can_construct_a_base_uri_from_a_schema>TestRefResolver.test_it_can_construct_a_base_uri_from_a_schemaC	  s   **665 7 
 	**E222E:#xX. $$X. %&(X. ''8X. (' $#$$&&''s0   -D	DD+.D<	
D
D(+
D9<
E
c                   0 n[         R                  R                  U5      nU R                  UR                  S5        U R                  UR
                  S5        UR                  S5       nU R                  X15        S S S 5        UR                  S5       nU R                  X15        S S S 5        g ! , (       d  f       N:= f! , (       d  f       g = f)Nr}   r  r  r  s       r   9test_it_can_construct_a_base_uri_from_a_schema_without_idITestRefResolver.test_it_can_construct_a_base_uri_from_a_schema_without_idT	  s    **66v>**B/22B7#xX. $$X. %$ $#$$s   +B1C1
B?
Cc                   ^ ^^ UUU 4S jnSS0mSm[         R                  " S0 SU0S9nUR                  T5       nT R                  UT5        S S S 5        g ! , (       d  f       g = f)Nc                ,   > TR                  U T5        T$ r5   r  )r  r=  r   r0   s    r   handler@TestRefResolver.test_custom_uri_scheme_handlers.<locals>.handler_	  s    S#&Mr3   r   r   	foo://barr}   handlers)r   r<  r  r)   )r0   r  r:  r  r=  r   s   `   @@r   test_custom_uri_scheme_handlers/TestRefResolver.test_custom_uri_scheme_handlers^	  s]    	 **2rUG<LM$Xv. %$$s   A
A%c                  ^ ^ [        5       /mUU 4S jnSn[        R                  " S0 SSU0S9nUR                  U5          S S S 5        UR                  U5          S S S 5        g ! , (       d  f       N*= f! , (       d  f       g = f)Nc                h   >  TR                  5       $ ! [         a    TR                  S5         g f = f)Nz#Response must not have been cached!r]   
IndexErrorr    r  responser0   s    r   r  5TestRefResolver.test_cache_remote_on.<locals>.handlerl	  s3    A||~% A		?@A    11r  r}   Tr   cache_remoter  r   r   r<  r  r0   r  r=  r:  r$  s   `   @r   test_cache_remote_on$TestRefResolver.test_cache_remote_oni	  sx    H:	A **0@
 $ %$ %$ %$$$s   A'A8'
A58
Bc                   ^ ^ [        5       /mUU 4S jnSn[        R                  " S0 SSU0S9nUR                  U5          S S S 5        g ! , (       d  f       g = f)Nc                h   >  TR                  5       $ ! [         a    TR                  S5         g f = f)NzHandler called twice!r!  r#  s    r   r  6TestRefResolver.test_cache_remote_off.<locals>.handler~	  s0    3||~% 3		123r&  r  r}   Fr   r'  r)  r*  s   `   @r   test_cache_remote_off%TestRefResolver.test_cache_remote_off{	  sU    H:	3 **%1A
 $ %$$s   A
Ac                  ^ [        S5      mU4S jnSn[        R                  " S0 SU0S9nU R                  [        R
                  5       nUR                  U5         U R                  S5        S S S 5        S S S 5        U R                  WR                  [        R
                  " T5      5        g ! , (       d  f       NG= f! , (       d  f       NP= f)NzOh no! What's this?c                   > Ter5   r   )r  r"  s    r   r  TTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error.<locals>.handler	  s    Kr3   r  r}   r   r  zShouldn't get this far!)
r  r   r<  r   r   _RefResolutionErrorr  r    r)   r  )r0   r  r=  r:  errr"  s        @r   3test_if_you_give_it_junk_you_get_a_resolution_errorCTestRefResolver.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$   CB10C1
B?	;C
Cc                .   [         R                  " S0 5      nUR                  5         U R                  [        R
                  5       nUR                  5         S S S 5        U R                  S[        WR                  5      5        g ! , (       d  f       N4= f)Nr}   zFailed to pop the scope)	r   r<  	pop_scoper   r   r5  r   r  r  )r0   r:  excs      r   .test_helpful_error_message_on_failed_pop_scope>TestRefResolver.test_helpful_error_message_on_failed_pop_scope	  sh    **2r2z==>#  ?/S]]1CD ?>s   B
Bc                   [         R                  R                  n[         R                  " SU5      n[         R                  " XS9nU R	                  UR                  SS05      5        SS[         R                  R                  S   0/0n[         R                  " SU5      n[         R                  " XES9nU R	                  UR                  SS05      5        g)	z
See #1085.
r}   r9  rh  r   allOfr   r%   N)r   r  r7   r<  r  r   )r0   r   oner   anothertwos         r   ,test_pointer_within_schema_with_different_id<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Br3   c                  ^  U 4S jn[         R                  " S0 SU0S9n[         R                  " 0 [         R                  R                  S9nSSS.nU" XBS	9nT R                  UR                  0 5      UR                  S
5      4S5        g)zZ
See https://github.com/python-jsonschema/jsonschema/issues/1061#issuecomment-1624266555.
c                0   > TR                  U S5        SS0$ )Nzhttp://example.com/foor   r   r  )r  r0   s    r   handleNTestRefResolver.test_newly_created_validator_with_ref_resolver.<locals>.handle	  s    S":;I&&r3   r}   httpr  r   zhttp://example.com/barr   )r%   r   r9  r   FTN)r   r<  r-   r   r6   r)   r   )r0   rG  r:  r.   r   r   s   `     r   .test_newly_created_validator_with_ref_resolver>TestRefResolver.test_newly_created_validator_with_ref_resolver	  s    
	' **2rVV<LM%%!11<<
	 25Af8	#Y%7%7%;<	
r3   c                    SSS00SSS00S.n[         R                  " U[         R                  " SU5      S9nU R                  UR	                  SS	05      UR	                  SS
05      4S5        g)zZ
See https://github.com/python-jsonschema/jsonschema/issues/1124#issuecomment-1632574249.
xr   z#/definitions/xr   r   )r  r  r}   r9  yr   rJ  N)r   r   r<  r)   r   )r0   r   r   s      r   2test_refresolver_with_pointer_in_schema_with_no_idBTestRefResolver.test_refresolver_with_pointer_in_schema_with_no_id	  s     ): ;<&)!45

 33,,R8
	 	c
+Y-?-?b	-JK	
r3   )r  r:  r8  N)r^   r   r_   r   r  r  r  r1   r  r  r  r  r  r  r	  r  r  r  r+  r0  r7  r<  rC  rK  rP  r   r   r3   r   r  r    st    HJx(M
)K	4++',./"/	/$ OEC 
*
r3   r  c                    S n[        XS9$ )Nc                    U R                    Vs/ s H  n[        U5      PM     snU R                   Vs/ s H  n[        U5      PM     sn4$ s  snf s  snf r5   )r  r  rI   )r"  r  s     r   keysorted_errors.<locals>.key	  sJ    "ZZ(ZSVZ("../.SV./
 	
(/s
   AA)rT  )sorted)r   rT  s     r   r  r  	  s    

 &""r3   c                  &    \ rS rSr% S\S'   S rSrg)r  i	  zdict[str, Any]
_responsesc                    U R                   R                  U5      nUc  [        S[        U5      -   5      e[	        [
        R                  " U5      5      $ )NzUnknown URL: )rX  r   r  rd   _ReallyFakeJSONResponser  r  )r0   r  r$  s      r   r   ReallyFakeRequests.get	  sC    ??&&s+;_tCy899&tzz(';<<r3   r   N)r^   r   r_   r   r  r   r   r   r3   r   r  r  	  s     =r3   r  c                  &    \ rS rSr% S\S'   S rSrg)rZ  i	  r  	_responsec                B    [         R                  " U R                  5      $ r5   )r  loadsr]  r/   s    r   r  _ReallyFakeJSONResponse.json	  s    zz$..))r3   r   N)r^   r   r_   r   r  r  r   r   r3   r   rZ  rZ  	  s     N*r3   rZ  ):
__future__r   collectionsr   r   
contextlibr   decimalr   ior   typingr	   unittestr
   r   urllib.requestr   r  r  r  r  rt  attrsr   r   referencing.jsonschemar   referencing.exceptionsr  
jsonschemar   r   r   r   r   r    r"   r   r  rV  rp  r  r
  r  r!  r#  r%  r)  r+  r0  r~  r  r  r  r  r  rZ  r   r3   r   <module>rm     s   " ) %    # '  	 
    .  1L6( L6^c
( c
L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
`# = = = * * *r3   