L iWddlmZddlmZmZddlmZddlmZddl m Z ddl m Z ddl mZmZddlmZdd lZdd lZdd lZdd lZdd lZdd lmZmZdd lmZdd lZdd lmZm Z m!Z!m"Z"m#Z#d Z$GddeZ%GddeZ&GddeZ'GddZ(Gdde(Z)GddZ*Gdde*e)eZ+Gdde*e)eZ,Gdde)eZ-Gd d!e)eZ.Gd"d#e)eZ/Gd$d%e)eZ0Gd&d'eZ1Gd(d)eZ2Gd*d+eZ3Gd,d-eZ4Gd.d/eZ5Gd0d1eZ6d2Z7eGd3d4Z8eGd5d6Z9y )7) annotations)deque namedtuple)contextmanager)Decimal)BytesIO)Any)TestCasemock) pathname2urlN)definefield) DRAFT202012) FormatChecker TypeChecker exceptions protocols validatorsc#lK|D]+}|jddtjdi|-yw)NmessagezYou told me to fail!) setdefaultrValidationError) validatorerrorsinstanceschemaeachs f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jsonschema/tests/test_validators.pyfailr s81  #9:((04001s24ceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZy)TestCreateAndExtendc|j|jtjt tj|j|jtj t tj ddi|_dti|_t|_ tj|j |j|j|_ y)N$idzsome://meta/schemar ) meta_schemar type_checker) addCleanup assertEqualr _META_SCHEMASdict _VALIDATORSr%r rr&create Validatorselfs rsetUpzTestCreateAndExtend.setUp$s      $ $ )) *      " " '' ( "#78!4.'M#**((** c|j|jj|jj|jjf|j |j |jfyN)r(r- VALIDATORS META_SCHEMA TYPE_CHECKERrr%r&r.s r test_attrszTestCreateAndExtend.test_attrs9s\ ))**++    !! r1cbdgi}|j|j|j|y)Nr )r(r-rr/rs r test_initzTestCreateAndExtend.test_initFs*" /66?r1cdgi}|j|}t|jd}|j|gy)Nr hello)r-list iter_errorsr(r/rrrs rtest_iter_errors_successfulz/TestCreateAndExtend.test_iter_errors_successfulJs>"NN6* i++G45 $r1c Pdddigi}|j|}tjdd|dddigtdg}t |j d}|j t|d|j |dj|jy)Nr rzWhoops!goodbye)rrrvalidator_value schema_pathr) r-rrrr=r>r(len _contents)r/rrexpected_errorrs rtest_iter_errors_one_errorz.TestCreateAndExtend.test_iter_errors_one_errorQsIy123NN6* #33 '34vh  i++I67 Va( ,,.0H0H0JKr1cdddidddddigi}|j|}t|jd}|jt |d y) Nr rFirstzSecond!asdf)rrThirdrB)r-r=r>r(rFr?s r test_iter_errors_multiple_errorsz4TestCreateAndExtend.test_iter_errors_multiple_errorsbsb G$%F;G$ NN6* i++I67 Va(r1cNtjddid}|jtjjd|jtj jd|j |jd|j |jdy)Nr$ something my versionr%versionMyVersionValidator) rr,r'r)popr+r(__name__ __qualname__r/r-s r.test_if_a_version_is_provided_it_is_registeredzBTestCreateAndExtend.test_if_a_version_is_provided_it_is_registeredos%% ,    0044kB  ..22LA ++-AB //1EFr1c tjddid}|jtjjd|jtj jd|j t|idy)Nr$rQrRrSz2MyVersionValidator(schema={}, format_checker=None))rr,r'r)rVr+r(reprrYs r test_reprzTestCreateAndExtend.test_reprysp%% ,    0044kB  ..22LA  2  @ r1c Htjddid}|jtjjd|jtj jd|j t|dttdidy)Nr$rQrRrSaizNMyVersionValidator(schema={'a': [0, 1, 2, 3, 4, 5, ...]}, format_checker=None)) rr,r'r)rVr+r(r\r=rangerYs rtest_long_reprz"TestCreateAndExtend.test_long_reprs%% ,    0044kB  ..22LA  CeDk!234 5' r1crtji}|jt|idy)Nr%z)Validator(schema={}, format_checker=None))rr,r(r\rYs rtest_repr_no_versionz(TestCreateAndExtend.test_repr_no_versions/%%"5   2  7 r1ctjddid}|jtjjd|jtj jd|j |jdy)Nr$rQzfoo-barrSFooBarValidator)rr,r'r)rVr+r(rXrYs r-test_dashes_are_stripped_from_validator_nameszATestCreateAndExtend.test_dashes_are_stripped_from_validator_namessj%% ,   0044kB  ..22I> //1BCr1cttj}tjddi|j tj|y)Nidrc)r*rr)r,r()r/originals r6test_if_a_version_is_not_provided_it_is_not_registeredzJTestCreateAndExtend.test_if_a_version_is_not_provided_it_is_not_registereds: 001tTl3 118zMTestCreateAndExtend.test_validates_registers_meta_schema_id..AEE$Or1r%rTid_ofrr,r'r)rVr+assertInr/meta_schema_keymy_meta_schemas r'test_validates_registers_meta_schema_idz;TestCreateAndExtend.test_validates_registers_meta_schema_idsr*0& +  0044oF  ..22LA oz'?'?@r1c&d}d|i}tj|d|jtjj||jtj jd|j |tjy)Nmeta schema $idr$rRrSryr{s r.test_validates_registers_meta_schema_draft6_idzBTestCreateAndExtend.test_validates_registers_meta_schema_draft6_idso+1&    0044oF  ..22LA oz'?'?@r1c tjid|jtfddgfddddd ifd fDy) Nrr%rc3VK|] \}}ij||"yw))rtypeN)is_type).0rrr-s r z@TestCreateAndExtend.test_create_default_types..s1 "D(" %%xd%C s&)array)booleanT)integer )nullN)numberg(@object)stringfoo)rr, assertTrueallrYs @rtest_create_default_typesz-TestCreateAndExtend.test_create_default_typessW%%"D    bM%#"$rN%'   r1cRtjtjjddiid}|j ddi|j t j5|j iddd|ddijdy#1swY#xYw)zq One can create a validator class whose metaschema uses a different dialect than itself. r$const)$schemanotrcrbarN) rr,Draft202012Validatorr5 check_schema assertRaisesr SchemaErrorvalidater/NoEmptySchemasValidators r+test_check_schema_with_different_metaschemaz?TestCreateAndExtend.test_check_schema_with_different_metaschemas #-"3"3%::FFuM}#  ,,eU^<   z55 6 5 # 0 0 4 5 /88? 5 5s )BB&ctjdddigidti}|jtj 5|j idddy#1swYyxYw)z A validator whose metaschema doesn't declare $schema defaults to its own validation behavior, not the latest "normal" specification. r rzMeta schema whoops!rN)rr,r rrrrrs r.id_ofs#::j$..*>*>v*FG Gr1zthe://correct/id/zthe://wrong/id/)r$r)r%rr&rxN)rr,r&r(rr5r)r/rx correct_idr%OriginalDeriveds` rtest_extend_idofz$TestCreateAndExtend.test_extend_idof s H( $" $$#**   (<(<=zJ##H- w':':;ZHr1cdddiiddd}tj|}|j|jdtjtj}|j||jdy) zV Extending a validator preserves its notion of applicable validators. testrrz #/$defs/testrE)$defs$refmaximum%N)rDraft4Validatorris_validr)r/rdraft4rs r!test_extend_applicable_validatorsz5TestCreateAndExtend.test_extend_applicable_validators sv vx01"  ++F3 +,##J$>$>? 0045r1N)rW __module__rXr0r7r:r@rIrOrZr]rardrgrkr~rrrrrrrrr1rr"r"#sn *  @%L" )G     D= A A "@& 5 ,I,6r1r"cheZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Zrr(rFr)r/rrargskwargsrrrs r message_forz'TestValidationErrorMessages.message_for3sjj : :;  000 i++H56 &@ $MN  K 4VJ?  ay   r1cR|jdddi}|j|dyNrErrrr1 is not of type 'string'rr(r/rs rtest_single_type_failurez4TestValidationErrorMessages.test_single_type_failure@s-""Avx6H"I "=>r1cT|jdddgi}|j|dyrrrs rtest_single_type_list_failurez9TestValidationErrorMessages.test_single_type_list_failureDs/""Avz6J"K "=>r1chd}|jddt|i}|j|dy)N)rrrErrz#1 is not of type 'string', 'object')rr=r()r/typesrs rtest_multiple_type_failurez6TestValidationErrorMessages.test_multiple_type_failureHs6"""AvtE{6K"L "GHr1c|ddddgi}|jd|tj}|j|dy)NrFoorN)nameminimumrErrrz1 is not of type 'Foo'rrDraft3Validatorr(r/rrs r#test_object_with_named_type_failurez?TestValidationErrorMessages.test_object_with_named_type_failureMsKEa89:""**#  ":;r1cR|jdddi}|j|dy)NrErrz1 is less than the minimum of 2rrs r test_minimumz(TestValidationErrorMessages.test_minimumVs,""Ay!n"E "CDr1cR|jdddi}|j|dy)NrErrrz"1 is greater than the maximum of 0rrs r test_maximumz(TestValidationErrorMessages.test_maximumZs,""Ay!n"E "FGr1cd\}}d||ii}|jddi|tj}|j|dyNrr dependenciesrrrz'foo' is a dependency of 'bar'rr/dependonrrs r test_dependencies_single_elementz""SE:**#  *G4r1cv|jgdgddtj}|jd|y)NrErrNFrrz(1, 2, 3 were unexpected)rrs r&test_additionalItems_multiple_failureszBTestValidationErrorMessages.test_additionalItems_multiple_failuress<""E:**#  17;r1c^d}ddi}|j|di|}|jd|y)NradditionalPropertiesFrrz('foo' was unexpected)rrz)r/ additionalrrs r(test_additionalProperties_single_failurezDTestValidationErrorMessages.test_additionalProperties_single_failures9 (%0""ZOF"K .8r1cddi}|jtjddg|}|jt d||jt d||jd|y)NrFrrrzwere unexpected))rr*fromkeysrzr\rs r+test_additionalProperties_multiple_failureszGTestValidationErrorMessages.test_additionalProperties_multiple_failuressi(%0""]]E5>2#  d5k7+ d5k7+ ('2r1cZddi}|jddi|}|jd|y)Nrrrrrz12 was expectedrrs r test_constz&TestValidationErrorMessages.test_consts;2""U^#  '1r1c~dddii}|jdigg|tj}|j|dy)Ncontainsrrrrz4None of [2, {}, []] are valid under the given schema)rrDraft6Validatorr(rs rtest_contains_draft_6z1TestValidationErrorMessages.test_contains_draft_6sPwm,""R[**#    B r1c td}|jddddi}|jd||}|jt d||jt d||jd|y) Nr)formatsthingcyNFr)values rruzQTestValidationErrorMessages.test_invalid_format_default_message..sr1formatbla)rrformat_checkerzis not a)rchecksrrzr\)r/checkerrrs r#test_invalid_format_default_messagez?TestValidationErrorMessages.test_invalid_format_default_messages|+w 34G$"""#  d5k7+ d7mW- j'*r1c ddddiddidd}|jddi|tj }|j|d j t dt d t d |jdd d|tj }|j|dj t dt dt d t d y)NrFrr)^abc$^def$)rrpatternPropertieszebra{rz,{} does not match any of the regexes: {}, {}rri)rfishz.{}, {} do not match any of the regexes: {}, {}r)rrrr(r r\rs r1test_additionalProperties_false_patternPropertieszMTestValidationErrorMessages.test_additionalProperties_false_patternPropertiess"*/ &1 &1( ""s^**#    : A AW tG}d7m  """C0**#    < C CV d7mT']DM  r1cN|jdd}|j|dy)NrQFrz'False schema does not allow 'something'rrs rtest_False_schemaz-TestValidationErrorMessages.test_False_schemas0"" #  "KLr1cR|jdddi}|j|dy)NrN multipleOfrrz3 is not a multiple of 2rrs rtest_multipleOfz+TestValidationErrorMessages.test_multipleOfs5"" !$#  "<=r1cR|jgddi}|j|dy)NminItemsrrz[] is too shortrrs r test_minItemsz)TestValidationErrorMessages.test_minItemss,""B A"G "34r1cV|jgdddi}|j|dy)NrmaxItemsrrz[1, 2, 3] is too longrrs r test_maxItemsz)TestValidationErrorMessages.test_maxItemss,""Iz1o"N "9:r1cR|jgddi}|j|dy)Nr!rErz[] should be non-emptyrrs rtest_minItems_1z+TestValidationErrorMessages.test_minItems_1s,""B A"G ":;r1cV|jgdddi}|j|dy)Nrr$rrz![1, 2, 3] is expected to be emptyrrs rtest_maxItems_0z+TestValidationErrorMessages.test_maxItems_0s,""Iz1o"N "EFr1cR|jdddi}|j|dy)Nrp minLengthrrz'' is too shortrrs rtest_minLengthz*TestValidationErrorMessages.test_minLengths5""##  "34r1cR|jdddi}|j|dy)Nabc maxLengthrrz'abc' is too longrrs rtest_maxLengthz*TestValidationErrorMessages.test_maxLengths5""##  "56r1cR|jdddi}|j|dy)Nrpr+rErz'' should be non-emptyrrs rtest_minLength_1z,TestValidationErrorMessages.test_minLength_1s-""B Q7G"H ":;r1cR|jdddi}|j|dy)Nr.r/rrz'abc' is expected to be emptyrrs rtest_maxLength_0z,TestValidationErrorMessages.test_maxLength_0s-""E;:J"K "ABr1cR|jiddi}|j|dy)N minPropertiesrrz"{} does not have enough propertiesrrs rtest_minPropertiesz.TestValidationErrorMessages.test_minPropertiess-""B7K"L "FGr1cZ|jiiidddi}|j|dy)N)r_bc maxPropertiesrrz3{'a': {}, 'b': {}, 'c': {}} has too many propertiesrrs rtest_maxPropertiesz.TestValidationErrorMessages.test_maxProperties"s?""BR0#Q'#    A r1cR|jiddi}|j|dy)Nr6rErz{} should be non-emptyrrs rtest_minProperties_1z0TestValidationErrorMessages.test_minProperties_1,s-""B7K"L ":;r1cV|jddiddi}|j|dy)NrErr;rrz{1: 2} is expected to be emptyrrs rtest_maxProperties_0z0TestValidationErrorMessages.test_maxProperties_00s9""V#Q'#  "BCr1c\|jgddiigd}|j|dy)N)rErrFr prefixItemsrz1Expected at most 2 items but found 1 extra: 'foo'rrs rtest_prefixItems_with_itemsz7TestValidationErrorMessages.test_prefixItems_with_items7s<""""B8<#    ? r1c\|jgddiigd}|j|dy)NrErrFrBrz6Expected at most 2 items but found 2 extra: ['foo', 5]rrs r*test_prefixItems_with_multiple_extra_itemszFTestValidationErrorMessages.test_prefixItems_with_multiple_extra_itemsAs<""%"B8<#    D r1cR|jdddi}|j|dy)Nbbbpatternz^a*$rz'bbb' does not match '^a*$'rrs r test_patternz(TestValidationErrorMessages.test_patternKs5""v&#  "?@r1cV|jgdddii}|j|dy)Nrrrrz3[] does not contain items matching the given schemarrs rtest_does_not_containz1TestValidationErrorMessages.test_does_not_containRs="" 23#    A r1c\|jddgddidd}|j|dy) NrrErrrr minContainsrMToo few items match the given schema (expected at least 2 but only 1 matched)rrs rtest_contains_too_fewz1TestValidationErrorMessages.test_contains_too_few\sC""QZ!' 21E#    7 r1c^|jddgddiddd}|j|d y) NrrErrrrrQ maxContainsrrRrrs r&test_contains_too_few_both_constrainedzBTestValidationErrorMessages.test_contains_too_few_both_constrainedgsI""QZ#X.  #     r1c\|jgdddidd}|j|dy)NrrbazrrrrrWr:Too many items match the given schema (expected at most 2)rrs rtest_contains_too_manyz2TestValidationErrorMessages.test_contains_too_manyvs=""*!' 21E#    H r1cb|jdgdzddiddd}|j|d y) NrrGrrrrUrVrz:Too many items match the given schema (expected at most 4)rrs r'test_contains_too_many_both_constrainedzCTestValidationErrorMessages.test_contains_too_many_both_constrainedsI""Wq[#X.  #    H r1cR|jdddi}|j|dy)NrNexclusiveMinimumrGrz+3 is less than or equal to the minimum of 5rrs rtest_exclusiveMinimumz1TestValidationErrorMessages.test_exclusiveMinimums8""&*#    9 r1cR|jdddi}|j|dy)NrNexclusiveMaximumrrz.3 is greater than or equal to the maximum of 2rrs rtest_exclusiveMaximumz1TestValidationErrorMessages.test_exclusiveMaximums1""A7I16M"N   < r1cT|jiddgi}|j|dy)Nrequiredrrz'foo' is a required propertyrrs r test_requiredz)TestValidationErrorMessages.test_requireds/""B UG7L"M "@Ar1c\|jdiidddgii}|j|dy)NrdependentRequiredrrz'bar' is a dependency of 'foo'rrs rtest_dependentRequiredz2TestValidationErrorMessages.test_dependentRequireds@""R['%%)9:#  "BCr1cT|jiddgi}|j|dy)NoneOfFrz.{} is not valid under any of the given schemasrrs rtest_oneOf_matches_nonez3TestValidationErrorMessages.test_oneOf_matches_nones2""B%7I"J   < r1cV|jidddgi}|j|dy)NrnTrz${} is valid under each of True, Truerrs rtest_oneOf_matches_too_manyz7TestValidationErrorMessages.test_oneOf_matches_too_manys1""B$7N"O "HIr1c\ddd}|jddg|}|j|dy)NrFrunevaluatedItemsrrrz@Unevaluated items are not allowed ('foo', 'bar' were unexpected)rrs rtest_unevaluated_itemsz2TestValidationErrorMessages.test_unevaluated_itemss7!u=""UEN6"J  N r1cXddd}|jd|}|j|dy)NrFrsrrz'foo' is not of type 'array'rrs r&test_unevaluated_items_on_invalid_typezBTestValidationErrorMessages.test_unevaluated_items_on_invalid_types2!u=""E&"A "@Ar1cldddiiddid}|jdddd| }|j|d y) Nrrrrr propertiesunevaluatedPropertiesrrZrz_Unevaluated properties are not valid under the given schema ('bar' was unevaluated and invalid)rrs r5test_unevaluated_properties_invalid_against_subschemazQTestValidationErrorMessages.test_unevaluated_properties_invalid_against_subschemas_ 68"45&-r] ""  #    2 r1c^ddd}|jddd|}|j|dy) NrFrr{rrrrrzEUnevaluated properties are not allowed ('bar', 'foo' were unexpected)rrs r&test_unevaluated_properties_disallowedzBTestValidationErrorMessages.test_unevaluated_properties_disallowedsI"UC"" #    - r1cXddd}|jd|}|j|dy)NrFr~rrz'foo' is not of type 'object'rrs r+test_unevaluated_properties_on_invalid_typezGTestValidationErrorMessages.test_unevaluated_properties_on_invalid_types2"UC""E&"A "ABr1c^igdd}|jgd|}|j|dy)NFrCrrZrz9Expected at most 1 item but found 2 extra: ['bar', 'baz']rrs rtest_single_itemz,TestValidationErrorMessages.test_single_items?"$6""*#    G r1c|igdd}|jgd|tj}|j|dy)NFrrrrrzr@rDrHrLrNrSrXr^r`rcrfrirlrorqrurwr|rrrrrrrrrr1rrr2s5 !??I <EHD  DD5<9 32   + <M>5;<G57<CH <D  A          BD J B  &  C            r1rceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZy)TestValidationErrorDetailsc6 d}dddiddigi}tj|}t|j|}|j t |d|d}|j |j d|j |j|d|j |j||j |j||j|j|j |jtg|j |jtg|j |jtg|j |j d |j |j"tdg|j |j$tdg|j |j&tdg|j t |j(d t+|j(\}}|j |j d|j |j|ddd|j |j||j |j|dd|j-|j||j |jtg|j |jtg|j |jtg|j |j d |j |j"tddg|j |j$tddg|j |j&tgd |j/|j(|j |j d|j |j|ddd|j |j||j |j|dd|j-|j||j |jtg|j |jtg|j |jtg|j |j d |j |j"tddg|j |j$tddg|j |j&tgd |j t |j(dy) NrGanyOfrrrrEr$r)rrr)rrEr)rrr=r>r(rFrrCrr assertIsNoneparentpathr relative_path absolute_path json_pathrDrelative_schema_pathabsolute_schema_pathcontext sorted_errorsassertIs assertFalser/rrrree1e2s r test_anyOfz%TestValidationErrorDetails.test_anyOf6sA B" ..v6 i++H56 Va( 1I g. **F7O< X. 6* !((# r+ %)4 %)4 c* wi(89 //y1AB //y1AB QYY+qyy)B y1 ++VG_Q-? -JK h/ F7OA$67 bii# %), ))595 ))595 s+ 9~)>? 00%I2GH   # #U+B%C  $ v. ++VG_Q-?-GH h/ F7OA$67 bii# %), ))595 ))595 s+ 6{);< 00%F 2DE 00%8L2MN RZZ!,r1c" ddi}dddiddddgiidgi}tj|}t|j|}|j t |d|d }|j |j d|j |j|d|j |j||j |j||j|j|j |jtg|j |jtg|j |jtg|j |j d |j |j"tdg|j |j$tdg|j |j&tdg|j t |j(dt+|j(\}}|j |j d|j |j|dd d|j |j||j |j|dd |j-|j||j |jtg|j |jtg|j |jtg|j |j d |j |j"td dg|j |j$td dg|j |j&tgd |j/|j(|j |j d|j |jdg|j |jd|j |jddgi|j-|j||j |jtdg|j |jtdg|j |jtdg|j |j d |j |j"tgd |j |j$tgd |j |j&tgd|j/|j(y)NrrErrrenumrrrzrr)rrr$.foo)rErzrr)rrErzrr)rrr=r>r(rFrrCrrrrrrrrrrDrrrrrrrs r test_typez$TestValidationErrorDetails.test_type{sG1: #$#(6A3-"8 ..v6 i++H56 Va( 1I f- **F6N; X. 6* !((# r+ %)4 %)4 c* vh8 //xA //xA QYY+qyy)B v. ++VF^A->v-FG h/ F6N1$56 bii# %), ))595 ))595 s+ 6{);< 00%F 2DE 00%8K2LM $ v. ++aS1 a( VaSM2 bii# %.1 ))5%>: ))5%>: w/  NNE"BC    # #U+K%L    # # : ; $r1cddgddd}dddid did gd d d i}tj|}|j|}t|\}}}}|j |j t dg|j |j t dg|j |j t dg|j |j t dg|j |jt dg|j |jt dg|j |jt dg|j |jt dg|j |jt dg|j |jt dg|j |jt dg|j |jt dg|j |jd|j |jd|j |jd|j |jd|j |jd |j |jd|j |jd|j |jdy)NrrEspam)rrr[quuxrzrrr! )rrU)rrrZrr[r$.barz$.bazrrr) rrr>rr(rrrrrr) r/rrrrrre3e4s rtest_single_nestingz.TestValidationErrorDetails.test_single_nestingsTaSVD )"A#%|< ..v6 &&x0&v.BB %.1 %.1 %.1 %.1 ))5%>: ))5%>: ))5%>: ))5%>: ))5%>: ))5%>: ))5%>: ))5%>: w/ w/ w/ w/ z2 v. y1 v.r1cddddgiddg}dddgddd gid d d id diddddd}tj|}|j|}t|\}}}}} } |j |j t g|j |j t dg|j |j t ddg|j |j t gd|j | j t gd|j | j t ddg|j |jd|j |jd|j |jd|j |jd|j | jd|j | jd|j |jt dg|j |jt ddg|j t|jgd|j t|jgd|j t| jgd |j t| jgd!|j |jd|j |jd|j |jd|j |jd |j | jd |j | jdy)"NrErr[rrrrrrNrrhTr!)rr[r)rrrr)rErr)rErr[rr$[0]z$[1].barz $[1].bar.barz $[1].bar.bazz$[1].foorr)rrzrr)rrzrrzrrh)rrzrrzr[r!)rrzrr) rrr>rr(rrrrDr=r) r/rrrrrrrre5e6s rtest_multiple_nestingz0TestValidationErrorDetails.test_multiple_nestingsq%!6?!8,"QF+ '$.#5$.?'   "..v6 &&x0!.v!6BBB %), %*- %E "34 %(9":; %(9":; %E "34 s+ v. z2 ~6 ~6 z2 x9 /@)AB   "H    K    K    "H  v. v. v. z2 z2 v.r1c ldddddgddiddd d iid d d giiddgdd d iid}dddddddiid id i}tj|}|j|\}|j|jt dg|j|j t gd|j|jd|j\}|j|jt gd|j|j t gd|j|jd|j\}|j|jt gd|j|j t gd|j|jdy)Nnoderrrchildrenrr^.*$rz#/definitions/node)rr)rr)rrhrzroot) definitionsrrhrzr_ab)rzrrz$.root)rrr_) rzrrrrzrrrrz$.root.children.a)rrr_rr)rzrrrrzrrrrrrzrrrrz$.root.children.a.children.ab) rrr>r(rrrrr)r/rrrrrrs rtest_recursivez)TestValidationErrorDetails.test_recursive,s (%+Z$8!'%)1$*(.0D-&6") '*!F,@#AB1 8  # &#%    ..v6  " "8 , %/:  " "E*I$J  h/ii ))51J+KL   # #U  &  ':;jj    e;   # #U& * 'FGr1cddd}ddddi}tj|}|j|}t|\}}|j |j t dg|j |j t dg|j |jd |j |jd |j |jd |j |jd y) NrrrrrrGrrrrrrr rrr>rr(rrrrr/rrrrrrs rtest_additionalPropertiesz4TestValidationErrorDetails.test_additionalPropertiess +(9*KL..v6 &&x0v&B %.1 %.1 w/ w/ v. y1r1cddd}dddiddidi}tj|}|j|}t|\}}|j |j t d g|j |j t d g|j |jd |j |jd |j |jd|j |jdy) NrErrrrrrrGrrrrrrs rtest_patternPropertiesz1TestValidationErrorDetails.test_patternPropertiessQ' )!1~" ..v6 &&x0v&B %.1 %.1 w/ w/ v. y1r1cddg}gdddd}tj|}|j|}t|\}}|j |j t dg|j |j t dg|j |jd|j |jd |j |jd |j |jd y) NrrErrGrrrr$[1]rrrrs rtest_additionalItemsz/TestValidationErrorDetails.test_additionalItemss1:(1a@  ..v6 &&x0v&B %*- %*- v. v. v. y1r1cgd}igdddd}tj|}|j|}t|\}}|j |j t dg|j |j t dg|j |jd|j |jd |j |jd |j |jd y) N)rrrErrGrrrErrz$[2]rrrrs rtest_additionalItems_with_itemsz:TestValidationErrorDetails.test_additionalItems_with_itemss$T(1a@  ..v6 &&x0v&B %*- %*- v. v. v. y1r1cddi}ddddiii}tj|}|j|\}|j|jd|j|j d|j|j tg|j|jd|j|jtddgy)Nrr propertyNamesrrz0'foo' should not be valid under {'const': 'foo'}r rrr>r(rrrrrrD)r/rrrerrors rtest_propertyNamesz-TestValidationErrorDetails.test_propertyNamess2;!EGU+;#<=..v6 &&x0 %0  MM >  U2Y/ #. **E?E2J,KLr1cddiddid}tj|}|jd\}|j|jd|j|j d|j|j tg|j|jd|j|jtddgy)Nrr )ifthen13 was expectedrrrr/rrrs r test_if_thenz'TestValidationErrorDetails.test_if_thenB-bM  ..v6 &&r* '2 (9: U2Y/ #. **E672C,DEr1cddiddid}tj|}|jd\}|j|jd|j|j d|j|j tg|j|jd|j|jtddgy) Nrrr)relserrrrrrs r test_if_elsez'TestValidationErrorDetails.test_if_elserr1c 2tjd}|jd\}|j|j|j |j |j|j|j|jfdddddtgdfy)NFrzFalse schema does not allow 12r) rrr>r(rrrCrrrDrr)r/rrs rtest_boolean_schema_Falsez4TestValidationErrorDetails.test_boolean_schema_Falses..u5 &&r*  %% !! 1b   r1c ddddii}}tjd|itjdi||i}|jd d i\}|j |j |j |j|j|j|j|j|jfd ddd td gdditddgd fy) NsomeRefrrrrrpstoreresolverr notAnIntegerz''notAnInteger' is not of type 'integer'r)rr _RefResolverr>r(rrrCrrrrDrr)r/refrrrs rtest_refz#TestValidationErrorDetails.test_ref's"869:M!NV.. SM,,RC=I &&~'>?  %%## !! :ug#-v67  r1c dddiiiddigi}tj|}|jgd\}}|j|j|j |j |j|j|j|j|jfddddtd gdditgd d f|j|j|j |j |j|j|j|j|jfd ddd tdgdditgddfy)NrCrrrrNrFrrEr)rCrrrz"5 is greater than the maximum of 3rG)rCrNr$[3] rrr>r(rrrCrrrrDrr)r/rr type_error min_errors rtest_prefixItemsz+TestValidationErrorDetails.test_prefixItemsFs[68"4b"y!n!MN33F; ) 5 56F G I ""$$**##((!!&&$$ ,qc "01  , !!##))""''  %%## 5qc A34  r1c ddiigd}tj|}|jgd\}}|j|j|j |j |j|j|j|j|jfddddtdgdditddgd f|j|j|j |j |j|j|j|j|jfd ddd td gdditddgd fy)NrrrB)rrrrUr[z2 is not of type 'string'rrErrz4 is not of type 'string'rUrNrrr/rrrrs rrDz6TestValidationErrorDetails.test_prefixItems_with_itemswsEh'4 33F; &&'BCB   ""      ,qc "w'(  ,   ""      ,qc "w'(  r1c ~ddidd}tj|}|jgd\}|j|j|j |j |j|j|j|j|jfdddgdtgddiddtdgd fy ) z `contains` + `maxContains` produces only one error, even if there are many more incorrectly matching elements. rrrr\)rrrrUr[rr]rWrrNrrs rr^z1TestValidationErrorDetails.test_contains_too_manys &x0C33F; &&'JK  %%## !! M3b $h/Bzl#  r1c ~ddidd}tj|}|jgd\}|j|j|j |j |j|j|j|j|jfdddgdtgddiddtdgd fy) NrrrrP)rrrUrRrQrrrrs rrSz0TestValidationErrorDetails.test_contains_too_fews%x0C33F; &&}5  %%## !! ?b $h/Bzl#  r1c ddidd}tj|}|jddg\}|j|j|j |j |j|j|j|j|jfddddiddgtgddiddtdgdfy) NrrrrPrUz7[2, 4] does not contain items matching the given schemarrrrs rtest_contains_nonez-TestValidationErrorDetails.test_contains_nones%x0C33F; &&1v.  %%## !! J"Ab $h/Bzl#  r1cdddgiidddgdid}tj|}|jdii\}}|j|j|j |j |j|j|j|j|j|jf d ddgitdgddgitgd tgd d f |j|j|j |j |j|j|j|j|j|jf d ddgitdgddgdtgd tgd d f y) Nrrhrapropz #/$defs/foor[)rrh)rrzz'bar' is a required property)rzrrhz$.apropz'baz' is a required property)rrr>r(rrrCrrrrDrrrrs rtest_ref_siblingz+TestValidationErrorDetails.test_ref_siblingsj5'23)!& 33F; &&}5B   ""    ''  /wi eW%9:9:  0   ""    ''  /wi &UG<9:9:  r1N)rWrrXrrrrrrrrrrrrrrrrDr^rSrrrr1rrr3stC-JK%Z%/N;/zcHJ2"2,2(2(M F F 2 >/ b2 h > < 6< r1rc0eZdZdZdZdZdZdZdZy)MetaSchemaTestsMixinc|jtj5|jj ddidddy#1swYyxYw)Nrzrrrrr-rr.s rtest_invalid_propertiesz,MetaSchemaTestsMixin.test_invalid_propertiesDsB   z55 6 < NN ' 'r(: ; < < < AAc|jtj5|jj ddidddy#1swYyxYw)Nr!1rr.s rtest_minItems_invalid_stringz1MetaSchemaTestsMixin.test_minItems_invalid_stringHsB   z55 6 ; NN ' 'S(9 : ; ; ;rc:|jtjtjhvrF|j t j 5|jjdgidddy|jjdgiy#1swYyxYw)z Technically, all the spec says is they SHOULD have elements, not MUST. (As of Draft 6. Previous drafts do say MUST). See #529. rNr-rrrrrrrr.s rtest_enum_allows_empty_arraysz2MetaSchemaTestsMixin.test_enum_allows_empty_arraysMs >>  & &  & &  "":#9#9: :++VRL9 : : NN ' ' 5 : :s BBcB|jtjtjhvrH|j t j 5|jjdddgidddy|jjdddgiy#1swYyxYw)z Technically, all the spec says is they SHOULD be unique, not MUST. (As of Draft 6. Previous drafts do say MUST). See #529. rrNrr.s r!test_enum_allows_non_unique_itemsz6MetaSchemaTestsMixin.test_enum_allows_non_unique_items^s >>  & &  & &  "":#9#9: @++Vb"X,>? @ @ NN ' '"b(: ; @ @s BBc|jtj5|jj ddidddy#1swYyxYw)NrK *notaregexrr.s rtest_schema_with_invalid_regexz3MetaSchemaTestsMixin.test_schema_with_invalid_regexosF   z55 6 C NN ' 'L(A B C C CrcB|jjddidy)NrKr r)r-rr.s r>test_schema_with_invalid_regex_with_disabled_format_validationzSMetaSchemaTestsMixin.test_schema_with_invalid_regex_with_disabled_format_validationss$ ##  % $ r1N) rWrrXrrr r rrrr1rrrBs!<; 6"<"C r1rc~eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZy)ValidatorTestMixincb|j|jitjyr3)assertIsInstancer-rr.s r)test_it_implements_the_validator_protocolz> )" ooH%>>88  >> X >>88mm"  h' C*r1c|jt5tGdd|j}dddid}|j |j gd|j ddi }|j |j gd|j |jdy#1swYxYw) ar Subclassing validators isn't supported public API, but some users have done it, because we don't actually error entirely when it's done :/ We need to deprecate doing so first to help as many of these users ensure they can move to supported APIs, but this test ensures that in the interim, we haven't broken those users. c2eZdZedZedZy):ValidatorTestMixin.test_evolve_with_subclass..OhNoc gdS)Nrrrr1rruzCValidatorTestMixin.test_evolve_with_subclass..OhNo.sIr1)factoryrdefaultN)rWrrXrr_barrr1rOhNor)s$56R(r1r/Nr)rrrrr) assertWarnsDeprecationWarningr r-r(rr"r.)r/r/rrs rtest_evolve_with_subclassz,ValidatorTestMixin.test_evolve_with_subclasss  0 1 )  )t~~ ) ) ) $   2vy&9: ), 2& ) )s B44B=cd|j|jijddy)Nrr)rr-rr.s r#test_is_type_is_true_for_valid_typez6ValidatorTestMixin.test_is_type_is_true_for_valid_types$ r*225(CDr1cd|j|jijddy)Nrrrr-rr.s r&test_is_type_is_false_for_invalid_typez9ValidatorTestMixin.test_is_type_is_false_for_invalid_types& +33E7CDr1c|j|jijdd|j|jijddy)NTrrr7r.s r,test_is_type_evades_bool_inheriting_from_intz?ValidatorTestMixin.test_is_type_evades_bool_inheriting_from_intsJ +33D)DE +33D(CDr1cdddii}tj|j|jjj dd}||}|j ddt dt dz gd igd dg}|j|j|Dcgc]}|jc}|ycc}w) Nrrrc^t|tttfxrt|t Sr3) isinstanceintfloatrboolrr s rruzGValidatorTestMixin.test_it_can_validate_with_decimals..s,zC0((2$UD11r1r&rEg?rrT) rrr-r6redefinerrr(r>r)r/rr-rrrs r"test_it_can_validate_with_decimalsz5ValidatorTestMixin.test_it_can_validate_with_decimalssFH-.%% NN44==2 f% AsGAJ$;<="b$- )2)>)>w)G HU^^ H  Hs#B?c`|jddit}|jdy)Nr carrotrbugs)r-rrr/rs r7test_it_returns_true_for_formats_it_does_not_know_aboutzJValidatorTestMixin.test_it_returns_true_for_formats_it_does_not_know_abouts1NN x #  6"r1c\|ji}|j|jyr3)r-rrrHs r,test_it_does_not_validate_formats_by_defaultz?ValidatorTestMixin.test_it_does_not_validate_formats_by_defaults$NN2&  )223r1ct}td|jdtfd}jddi|}|j dj t j5}|j ddddjjjy#1swY0xYw) NzBad!r)raisescJ|dk(ry|dk(rjd|dy)NgoodTbadzWhat is z? [Baby Don't Hurt Me])r )r rPr/s rcheckzTValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provided..checks/%  HUG+ABCr1r rrOrP) r ValueErrorrr-rrrrr exceptioncause)r/rrQrcmrPs` @r2test_it_validates_formats_if_a_checker_is_providedzEValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provideds/  j 1 D 2 DNN u g#  6"   z99 : &b   u % & bll((#.  & &s =B>>Cct}d|gi}tj|j|jjj |d}||j dy)Nrc"t|tSr3r=r>rAs rruz@ValidatorTestMixin.test_non_string_custom_type..s z%'=r1rBr)rrrr-r6rCr)r/non_string_typerCrazys rtest_non_string_custom_typez.ValidatorTestMixin.test_non_string_custom_types_ (?+,!! NN44===  f r"r1cttj|j|jjj dd}|j t j5}|ddijdddd|jdtjy#1swY/xYw) zh A tuple instance properly formats validation errors for uniqueItems. See #224 rc"t|tSr3)r=tuplerAs rruzNValidatorTestMixin.test_it_properly_formats_tuples_in_errors.. s z%'?r1rB uniqueItemsT)rErENz(1, 1) has non-unique elements) rrr-r6rCrrrrrzstrrS)r/TupleValidatorrs r)test_it_properly_formats_tuples_in_errorsz.sJe}5r1c(t|tfSr3)r=r*)rr res rruzBValidatorTestMixin.test_check_redefined_sequence..sZi06r1)rrrB)r_NrrpTFrr_)r_r9r_N) rrrr-r6 redefine_manyrrrrr)r/rr-rvalid_instancesrinvalid_instancesres @rtest_check_redefined_sequencez0ValidatorTestMixin.test_check_redefined_sequencesY"$7{F3 %% NN44BB    f%  , - E7QC. ! E7^UA3Z (UGn qc | ,w !" #s ~&6%7 8 E5'N# $eUA3ZL&9 : sA  #u 5 6#qc |,#ug/0  # #uaSz :;<# #ueW~ >?@ 5w( )5uaSz1B+C D! &( )H   x ( ) / " E7UG$ % E7^UE7^ ,UGn ug/ 0w !" #w(8'9&:%; < E5'N# $eUE7^,<&= > sE "Ic5$9 :#ug/0#ug/0  # #ueW~ >?@# #ueW~ >?@ 5w( )5ueW~1F+G H! &* -H"":#=#=> -""8, - - - - -s L;;M c|jt5|jij}ddd|j t j y#1swY*xYwr3)r1r2r-rrrr)r/rs r.test_it_creates_a_ref_resolver_if_not_providedzAValidatorTestMixin.test_it_creates_a_ref_resolver_if_not_providedTsP   0 1 3~~b)22H 3 h (?(?@ 3 3s AA$cdddi}}tjdi||i}|jd|i|}|jtj 5|j ddddy#1swYyxYw)N someCoolRefrrrprrr)rrr-rrrrr/rrrrs r/test_it_upconverts_from_deprecated_RefResolverszBValidatorTestMixin.test_it_upconverts_from_deprecated_RefResolversYsu#fi%8V**2r#vGNNFC=8ND   z99 : %   t $ % % %s A00A9cGfdd}|}ddi}jtj5j||j ddddy#1swYyxYw)zb Legacy RefResolvers support only the context manager form of resolution. c"eZdZefdZy)nValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolvers..LegacyRefResolverc3>Kj|dddiyw)Nthe refrrr()thisrr/s r resolvingzxValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolvers..LegacyRefResolver.resolvinghs"  i0y))sN)rWrrXrryr.srLegacyRefResolverrtgs  * *r1rzrrvrN)rrrr-r)r/rzrrs` r@test_it_upconverts_from_yet_older_deprecated_legacy_RefResolverszSValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolversasi  * * %&)$   z99 : E NN6HN 5 > >t D E E Es #A$$A-N)rWrrXrrrrr&r3r5r8r:rDrIrKrVr\rcrkrmrqr{rr1rrrzsmGCDI+('.EEE *# 4/0 #J"@-DA %Er1rc(eZdZdZdZdZdZdZy)AntiDraft6LeakMixinzN Make sure functionality from draft 6 doesn't leak backwards in time. c|jtj5}|jj dddd|j dt jy#1swY/xYw)NTzTrue is not of typerrrr-rrzrarSr/rs rtest_True_is_not_a_schemaz-AntiDraft6LeakMixin.test_True_is_not_a_schemaysW   z55 6 .! NN ' ' - . +S-=> . . A**A3c|jtj5}|jj dddd|j dt jy#1swY/xYw)NFzFalse is not of typerrs rtest_False_is_not_a_schemaz.AntiDraft6LeakMixin.test_False_is_not_a_schema~sW   z55 6 /! NN ' ' . / ,c!++.>? / /rc|jt5}|jdjdddd|j j t jy#1swY4xYw)NTrr Exceptionr-rassertNotIsInstancerSrrrs r5test_True_is_not_a_schema_even_if_you_forget_to_checkzIAntiDraft6LeakMixin.test_True_is_not_a_schema_even_if_you_forget_to_checksX   y ) .Q NN4 ) )" - .   j.H.HI . . !A**A3c|jt5}|jdjdddd|j j t jy#1swY4xYw)NFrrrs r6test_False_is_not_a_schema_even_if_you_forget_to_checkzJAntiDraft6LeakMixin.test_False_is_not_a_schema_even_if_you_forget_to_checksX   y ) /Q NN5 ! * *2 . /   j.H.HI / /rN)rWrrX__doc__rrrrrr1rr}r}ts? @ J Jr1r}c\eZdZUejZiifZded<ddidfZdZ dZ dZ d Z y ) TestDraft3Validatortuple[dict, dict]rrrrc\|jddi}|jtyNrany)r-rrrHs r#test_any_type_is_valid_for_type_anyz7TestDraft3Validator.test_any_type_is_valid_for_type_anys$NNFE?3 68$r1cPtj|j|jjj dd}|ddi}|j d|j tj5|j ddddy#1swYyxYw)z( Sigh, because why not. rc"t|tSr3rYrAs rruzBTestDraft3Validator.test_any_type_is_redefinable..s j.Dr1rBrrrN) rrr-r6rCrrrr)r/r[rs rtest_any_type_is_redefinablez0TestDraft3Validator.test_any_type_is_redefinables!! NN44==D  65/* 2   z99 : &   u % & & &s BB%cv|j|jddijtyr)rr-rrr.s r!test_is_type_is_true_for_any_typez5TestDraft3Validator.test_is_type_is_true_for_any_types( 7@@JKr1c|j|jijdd|j|jddijdy)NTrrr)rr-rrr.s r6test_is_type_does_not_evade_bool_if_it_is_being_testedzJTestDraft3Validator.test_is_type_does_not_evade_bool_if_it_is_being_testedsH r*224CD 7@@FGr1N) rWrrXrrr-r__annotations__rrrrrrr1rrrsA**I "BxE 'y!5(G% &LHr1rcDeZdZUejZiifZded<ddidfZy)TestDraft4ValidatorrrrrrN) rWrrXrrr-rrrrr1rrr+**I "BxE 'y!5(Gr1rcDeZdZUejZiifZded<ddidfZy)TestDraft6ValidatorrrrrrN) rWrrXrrr-rrrrr1rrrrr1rcDeZdZUejZiifZded<ddidfZy)TestDraft7ValidatorrrrrrN) rWrrXrrr-rrrrr1rrrrr1rcDeZdZUejZiifZded<ddidfZy)TestDraft201909ValidatorrrrrrN) rWrrXrDraft201909Validatorr-rrrrr1rrr+//I "BxE 'y!5(Gr1rcDeZdZUejZiifZded<ddidfZy)TestDraft202012ValidatorrrrrrN) rWrrXrrr-rrrrr1rrrrr1rceZdZdZdZy)TestLatestValidatorzQ These really apply to multiple versions but are easiest to test on one. cd}d|i}tjdi|di}tj||}|jtj 5|j ddddy#1swYyxYw)NrorrpFrr)rrrrrrrrps r2test_ref_resolvers_may_have_boolean_schemas_storedzFTestLatestValidator.test_ref_resolvers_may_have_boolean_schemas_storedsq#**2r#uF..vI   z99 : %   t $ % % %s A22A;N)rWrrXrrrr1rrrs %r1rcfeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZy)TestValidatorForcddi}|jtj|tjddi}|jtj|tjy)Nr&http://json-schema.org/draft-03/schema'http://json-schema.org/draft-03/schema#)rr validator_forrr9s r test_draft_3zTestValidatorFor.test_draft_3`EF  $ $V ,  & & FG  $ $V ,  & & r1cddi}|jtj|tjddi}|jtj|tjy)Nr&http://json-schema.org/draft-04/schema'http://json-schema.org/draft-04/schema#)rrrrr9s r test_draft_4zTestValidatorFor.test_draft_4rr1cddi}|jtj|tjddi}|jtj|tjy)Nr&http://json-schema.org/draft-06/schema'http://json-schema.org/draft-06/schema#)rrrrr9s r test_draft_6zTestValidatorFor.test_draft_6rr1cddi}|jtj|tjddi}|jtj|tjy)Nr&http://json-schema.org/draft-07/schema'http://json-schema.org/draft-07/schema#)rrrrr9s r test_draft_7zTestValidatorFor.test_draft_7rr1cddi}|jtj|tjddi}|jtj|tjy)Nrz,https://json-schema.org/draft/2019-09/schemaz-https://json-schema.org/draft/2019-09/schema#)rrrrr9s rtest_draft_201909z"TestValidatorFor.test_draft_201909`KL  $ $V ,  + + LM  $ $V ,  + + r1cddi}|jtj|tjddi}|jtj|tjy)Nr,https://json-schema.org/draft/2020-12/schema-https://json-schema.org/draft/2020-12/schema#)rrrrr9s rtest_draft_202012z"TestValidatorFor.test_draft_202012rr1cj|jtjdtjy)NTrrrrr.s r test_TruezTestValidatorFor.test_True*s%  $ $T *  & & r1cj|jtjdtjyr rr.s r test_FalsezTestValidatorFor.test_False0s%  $ $U +  & & r1ctjddidd}ddi}|jtj||y)Nrirm12c&|jddSrorqrss rruz8TestValidatorFor.test_custom_validator..:rvr1rwrrr,rrr/r-rs rtest_custom_validatorz&TestValidatorFor.test_custom_validator6sK%%/0+ -.  $ $V ,  r1ctjddid}ddi}|jtj||y)Nr$r13rSrrrs rtest_custom_validator_draft6z-TestValidatorFor.test_custom_validator_draft6BsH%% 12 ./  $ $V ,  r1cj|jtjitjyr3rr.s r%test_validator_for_jsonschema_defaultz6TestValidatorFor.test_validator_for_jsonschema_defaultMs! j..r2J4N4NOr1cR|jtjiddy)Nr,)rrrr.s r!test_validator_for_custom_defaultz2TestValidatorFor.test_validator_for_custom_defaultPs j..r4@$Gr1c|jt5}tjddiddd|j j t |j t|jdy#1swYOxYw)Nr unknownSchemar0zThe metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.) r1r2rrr(filename__file__rawarning)r/rUs r1test_warns_if_meta_schema_specified_was_not_foundzBTestValidatorFor.test_warns_if_meta_schema_specified_was_not_foundSss   0 1 JR  $ $Y,H I J h/   O &  J Js A==Bctjd5}tjdtjiiddd|j y#1swYxYw)NTrecordalways)rr-)warningscatch_warnings simplefilterrrr)r/ws r0test_does_not_warn_if_meta_schema_is_unspecifiedzATestValidatorFor.test_does_not_warn_if_meta_schema_is_unspecified_sU  $ $D 1 TestValidatorFor.test_validator_for_custom_default_with_schemaes.$&>? j..vw?Ir1N)rWrrXrrrrrrrrrrrrrrrrr1rrrsP                 PH   Jr1rcHeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) TestValidatecg}tjj|d|j5t j i|ddd|j ||gy#1swYxYw)Nr)r patchrappendrrr()r/rr-results r assertUseszTestValidate.assertUsesksX ZZ  y.&-- H ,   F + , &* , ,s A!!A*c|jdditj|jdditjy)Nrrrr-r)rrrr.s rtest_draft3_validator_is_chosenz,TestValidate.test_draft3_validator_is_chosenqJ HI 00  GH 00  r1c|jdditj|jdditjy)Nrrrr)rrrr.s rtest_draft4_validator_is_chosenz,TestValidate.test_draft4_validator_is_chosen|rr1c|jdditj|jdditjy)Nrrrr)rrrr.s rtest_draft6_validator_is_chosenz,TestValidate.test_draft6_validator_is_chosenrr1c|jdditj|jdditjy)Nrrrr)rrrr.s rtest_draft7_validator_is_chosenz,TestValidate.test_draft7_validator_is_chosenrr1c|jdditj|jdditjy)Nrrrrrrrr.s r$test_draft202012_validator_is_chosenz1TestValidate.test_draft202012_validator_is_chosensR J!55   I!55  r1cF|jitjy)Nrrr.s r)test_draft202012_validator_is_the_defaultz6TestValidate.test_draft202012_validator_is_the_defaults rZ-L-LMr1c|jtj5}tjdddiddd|j t jdy#1swY/xYw)Nrrrz1(?s)Failed validating '.*' in schema.*On instance)rrrrr assertRegexrarSrs rtest_validation_error_messagez*TestValidate.test_validation_error_messages_   z99 : 8a   VX$6 7 8    ?  8 8 A''A0c|jtj5}tjdddiddd|j t jdy#1swY/xYw)Nrrz3(?s)Failed validating '.*' in metaschema.*On schema)rrrrrrrarSrs rtest_schema_error_messagez&TestValidate.test_schema_error_messages^   z55 6 2!   VRL 1 2    A  2 2rcddddddigi}|jtj5}tjd|ddd|j dt jy#1swY/xYw) Nrnrrrrrrz!12 is less than the minimum of 20)rrrrrrzrarS)r/rrs rtest_it_uses_best_matchz$TestValidate.test_it_uses_best_matchsv !b1!    z99 : ,a   F + , 93q{{;KL , ,s A00A9N) rWrrXrrrrrrrrrr rr1rrrjs6+          N   Mr1rceZdZdZdZy) TestThreadinga Threading-related functionality tests. jsonschema doesn't promise thread safety, and its validation behavior across multiple threads may change at any time, but that means it isn't safe to share *validators* across threads, not that anytime one has multiple threads that jsonschema won't work (it certainly is intended to). These tests ensure that this minimal level of functionality continues to work. cgfd}|ddlm}||}|j|j|j |j fdgfy)Nc tjddy#jtjYyxYw)NrTr)rrrsysexc_info)failedsrrzFTestThreading.test_validation_across_a_second_thread..validates1 .##R= . clln-s %Ar)Thread)targetF) threadingrstartjoinr(is_alive)r/rrthreadrs @r&test_validation_across_a_second_threadz4TestThreading.test_validation_across_a_second_threadsS .  $x(   &//+V4ubkBr1N)rWrrXrrrr1rr r s  Cr1r ceZdZdZdZy)TestReferencingcd}tj|}ddi}tj||}|j |j d|j dfdy) Nc0tjddiS)Nrr)rcreate_resource)uris rretrievez=TestReferencing.test_registry_with_retrieve..retrieves.. /BC Cr1)rrhttps://example.com/registryrr)TF) referencingRegistryrrr(r)r/rr"rrs rtest_registry_with_retrievez+TestReferencing.test_registry_with_retrievesf D'':0133FXN      #Y%7%7%> ?  r1ctj}ddi}tj||}t j d5}t j d|jtjj5|jddddddd|jy#1swY#xYw#1swY'xYw)Nrr r!Trrr) r#r$rrrrrrr Unresolvablerr)r/r"rrrs r;test_custom_registries_do_not_autoretrieve_remote_resourceszKTestReferencing.test_custom_registries_do_not_autoretrieve_remote_resourcess'')0133FXN  $ $D 1 'Q  ! !( +"";#9#9#F#FG '""2& ' '  ' ' ' 's$?CB9C9C >CCN)rWrrXr%r(rr1rrrs    r1rceZdZdZdZddiZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZy)TestRefResolverrpz foo://storedstoredrci|_|j|ji|_t j |j |j|j|_yr3)referrer stored_uri stored_schemarrrbase_urirr.s rr0zTestRefResolver.setUp sD oot'9'9: "// MM4==$**  r1ctjjd}tjj |j d5}|j j|5} dddddd|jtjj|jjy#1swYWxYw#1swY[xYw)Nriresolve_remote) rrr5r rrrryr(rcalled)r/rpatchedresolveds r6test_it_does_not_retrieve_schema_urls_from_the_networkzFTestRefResolver.test_it_does_not_retrieve_schema_urls_from_the_network s((44T: ZZ  t}}.> ? 7((-    :#=#=#I#IJ (    s$C$B<&C<C CCcd}dti|jd<|jj|5}|j ||jdddddy#1swYyxYw)Nz#/properties/foorrz)rr-rryr()r/rr5s rtest_it_resolves_local_refsz+TestRefResolver.test_it_resolves_local_refs sg ',fh&7 l# ]] $ $S ) KX   Xt}}\'B5'I J K K Ks #A##A,cBdddid}tjj|d}|jd5}|j ||dddd|jd 5}|j ||ddddy#1swY9xYw#1swYyxYw) Nzhttp://bar/schema#rr)rir_c&|jddSrorqr0s rruzETestRefResolver.test_it_resolves_local_refs_with_id..# D"!5r1rxz#/ar_zhttp://bar/schema#/a)rr from_schemaryr(r/rrr5s r#test_it_resolves_local_refs_with_idz3TestRefResolver.test_it_resolves_local_refs_with_id s,E5>B**66 57    & 4(   Xvc{ 3 4    6 7 48   Xvc{ 3 4 4 4 4 4 4sB *B BBcj|jj|j5}|j||jdddddi|jj d<|jjd5}|j |ddddy#1swY[xYw#1swYyxYw)Nrr cached_refzcached_ref#/foo)rryr.rr/rr()r/r5s rtest_it_retrieves_stored_refsz-TestRefResolver.test_it_retrieves_stored_refs* s ]] $ $T__ 5 8 MM(D$6$6 7 8.3BK L) ]] $ $%6 7 +8   Xr * + +  8 8 + +sBB)B&)B2cld}ddi}dtjvr<|jtjjdtjdt d|itjd<|j j |5}|j|ddddy#1swYyxYw)Nhttp://bar#bazr[rrequests http://bar)rmodulesr' __setitem__ReallyFakeRequestsrryr()r/rrr5s r,test_it_retrieves_unstored_refs_via_requestsz.fake_urlopenI s6   S, /$**V,33F;< .b r;r1r<rp#zfoo#rrr=r(r0resolution_scoperyr>s r.test_it_can_construct_a_base_uri_from_a_schemaz>TestRefResolver.test_it_can_construct_a_base_uri_from_a_schema^ s3**66 57  **E2 22E:    # /x   Xv . /    $ /   Xv . /    & /(   Xv . /    ' /8   Xv . / /  / / / / / / / /s00DDD(4D4DD%(D14D=ci}tjj|}|j|jd|j|j d|j d5}|j||ddd|j d5}|j||dddy#1swY6xYw#1swYyxYw)Nrprcrdr>s r9test_it_can_construct_a_base_uri_from_a_schema_without_idzITestRefResolver.test_it_can_construct_a_base_uri_from_a_schema_without_ido s**66v> **B/ 22B7    # /x   Xv . /    $ /   Xv . / / / / / /s+B3B?3B<?Ccfd}ddidtjdid|i}|j5}j|dddy#1swYyxYw)Nc,j|Sr3rw)rQrrr/s rhandlerz@TestRefResolver.test_custom_uri_scheme_handlers..handlerz s   S# &Mr1rr foo://barrphandlers)rrryr()r/rkrr5rrs` @@rtest_custom_uri_scheme_handlersz/TestRefResolver.test_custom_uri_scheme_handlersy sf **2rUG.handler s3 A||~% A ?@ A 00rlrpTr cache_remoternrrrryr/rkrrrus` @rtest_cache_remote_onz$TestRefResolver.test_cache_remote_on sH: A ** 0@    $       $        sA(A4(A14A=ctgfd}d}tjdidd|i}|j|5 dddy#1swYyxYw)Ncf jS#t$rjdYywxYw)NzHandler called twice!rrrts rrkz6TestRefResolver.test_cache_remote_off..handler s0 3||~% 3 12 3rvrlrpFrrwryrzs` @rtest_cache_remote_offz%TestRefResolver.test_cache_remote_off s^H: 3 ** %1A    $     s A  Actdfd}d}tjdid|i}|jtj 5}|j |5|jddddddd|jjt j y#1swYAxYw#1swYExYw)NzOh no! What's this?cr3r)rQrs rrkzTTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error..handler sKr1rlrprrmzShouldn't get this far!) rRrrrr_RefResolutionErrorryr r(rS)r/rkrrerrrs @r3test_if_you_give_it_junk_you_get_a_resolution_errorzCTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error s01 **2rUG 5###C( 5 34 5 5  (F(Fu(MN 5 5 5 5s$ B=B11B=1B: 6B==Cc"tjdi}|j|jtj 5}|jddd|j dtjy#1swY/xYw)NrpzFailed to pop the scope) rr pop_scoperrrrzrarS)r/rexcs r.test_helpful_error_message_on_failed_pop_scopez>TestRefResolver.test_helpful_error_message_on_failed_pop_scope so**2r2   z== > !#     ! /S]]1CD ! !s BBctjj}tjd|}tj||}|j |j ddiddtjjdigi}tjd|}tj||}|j |j ddiy) z See #1085. rprr/rallOfrr$N)rrr5rrr)r/roneranothertwos r,test_pointer_within_schema_with_different_idz.handle s   S": ;I& &r1rphttprmrzhttp://example.com/barr)r$rrrFTN)rrr,rr4r(r)r/rrr-rrs` r.test_newly_created_validator_with_ref_resolverz>TestRefResolver.test_newly_created_validator_with_ref_resolver s  '**2rVV.key s@"ZZ (SV (".. /SV /  ( /s AA )r)sorted)rrs rrr s &c ""r1ceZdZUded<dZy)rIzdict[str, Any] _responsesc|jj|}|tdt|zt t j |S)Nz Unknown URL: )rrrrRr\_ReallyFakeJSONResponserNrO)r/rQrus rrrzReallyFakeRequests.get sC??&&s+ ;_tCy89 9&tzz(';<rs")%#' .1 L6(L6^~ (~ BL  L  ^5 5 pwE-wEtJJ4H-/A8H@)-/A8) ),h) ),h) )18) )18) %( %LJxLJ^^M8^MBCHC>h4l hl `#===***r1