VULN_CHECK_I913V6 % g-HddlmZddlmZmZddlmZddlmZddl 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 E/usr/lib/python3.12/site-packages/jsonschema/tests/test_validators.pyfailr s3  #9:((0400s24ceZdZdZdZdZdZdZdZdZ 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..s5 'ND(" %%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 # 0 0 47 /88?7 6s )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"ceZdZdZdZdZdZdZdZdZ 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/y.)/TestValidationErrorMessagesc:|jdtj}|j|||g|i|}t |j |}|j |d||jt|dd||djS)NclszNo errors were raised for )msgrEz"Expected exactly one error, found r) rVr_LATEST_VERSIONrr=r>rr(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..ser1formatbla)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:r1c\|jgddiigd}|j|dy)NrErrFr prefixItemsrz%Expected at most 2 items, but found 4rrs rtest_prefixItems_with_itemsz7TestValidationErrorMessages.test_prefixItems_with_itemss9""%"B8<#  "IJr1cR|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)Nbbbpatternz^a*$rz'bbb' does not match '^a*$'rrs r test_patternz(TestValidationErrorMessages.test_patterns5""v&#  "?@r1cV|jgdddii}|j|dy)Nrrrrz3[] does not contain items matching the given schemarrs rtest_does_not_containz1TestValidationErrorMessages.test_does_not_contains="" 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) NrrErrrrr: maxContainsrr;rrs r&test_contains_too_few_both_constrainedzBTestValidationErrorMessages.test_contains_too_few_both_constrained1sI""QZ#X.  #     r1c\|jgdddidd}|j|dy)Nrrbazrrrrr@r:Too many items match the given schema (expected at most 2)rrs rtest_contains_too_manyz2TestValidationErrorMessages.test_contains_too_many@s=""*!' 21E#    H r1cb|jdgdzddiddd}|j|d y) Nrr'rrrr>r?rz:Too many items match the given schema (expected at most 4)rrs r'test_contains_too_many_both_constrainedzCTestValidationErrorMessages.test_contains_too_many_both_constrainedJsI""Wq[#X.  #    H r1cR|jdddi}|j|dy)NrNexclusiveMinimumr'rz+3 is less than or equal to the minimum of 5rrs rtest_exclusiveMinimumz1TestValidationErrorMessages.test_exclusiveMinimumXs8""&*#    9 r1cR|jdddi}|j|dy)NrNexclusiveMaximumrrz.3 is greater than or equal to the maximum of 2rrs rtest_exclusiveMaximumz1TestValidationErrorMessages.test_exclusiveMaximumbs1""A7I16M"N   < r1cT|jiddgi}|j|dy)Nrequiredrrz'foo' is a required propertyrrs r test_requiredz)TestValidationErrorMessages.test_requiredis/""B UG7L"M "@Ar1c\|jdiidddgii}|j|dy)NrdependentRequiredrrz'bar' is a dependency of 'foo'rrs rtest_dependentRequiredz2TestValidationErrorMessages.test_dependentRequiredms@""R['%%)9:#  "BCr1cR|jiddi}|j|dy)N minPropertiesrrz"{} does not have enough propertiesrrs rtest_minPropertiesz.TestValidationErrorMessages.test_minPropertiests-""B7K"L "FGr1cZ|jiiidddi}|j|dy)N)r_bc maxPropertiesrrz3{'a': {}, 'b': {}, 'c': {}} has too many propertiesrrs rtest_maxPropertiesz.TestValidationErrorMessages.test_maxPropertiesxs?""BR0#Q'#    A r1cT|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)Nr_Trz${} 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 ('bar', 'foo' were unexpected)rrs rtest_unevaluated_itemsz2TestValidationErrorMessages.test_unevaluated_itemss7!u=""UEN6"J  N r1cXddd}|jd|}|j|dy)NrFrdrrz'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) propertiesunevaluatedPropertiesrrCrz_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) NrFrrkrrrrrzEUnevaluated properties are not allowed ('bar', 'foo' were unexpected)rrs r&test_unevaluated_properties_disallowedzBTestValidationErrorMessages.test_unevaluated_properties_disallowedsI"UC"" #    - r1cXddd}|jd|}|j|dy)NrFrnrrz'foo' is not of type 'object'rrs r+test_unevaluated_properties_on_invalid_typezGTestValidationErrorMessages.test_unevaluated_properties_on_invalid_types2"UC""E&"A "ABr1N)0rWrrXrrrrrrrrrrrrrrrrrrrrrr!r$r*r-r1r5r7r<rArGrIrLrOrRrUrXr]r`rbrfrhrlrprrrr1rrr2s !??I <EHD  DD5<9 32   + <M>5;K57A          BDH  J B  &  Cr1rceZdZdZdZdZdZdZdZdZ 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) Nr'anyOfrrrrEr$r)rvrr)rvrEr)rrr=r>r(rFrrCrr assertIsNoneparentpathr relative_path absolute_path json_pathrDrelative_schema_pathabsolute_schema_pathcontext sorted_errorsassertIs assertFalser/rrrree1e2s r test_anyOfz%TestValidationErrorDetails.test_anyOfsA 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)NrrErrrenumrrrjrrx)rrr$.foo)rErjrr)rrErjrr)rrr=r>r(rFrrCrrryrzr{rr|r}r~rDrrrrrrrs 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)rrrDquuxrjrrr  )rr>)rrrCrrDr$.barz$.bazrrr) rrr>rr(r{rr|r}r~r) r/rrrrrre3e4s rtest_single_nestingz.TestValidationErrorDetails.test_single_nestingWsTaSVD )"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)"NrErrDrorrrrrNrrQTr )rrDr)rrrr)rErr)rErrDrrx$[0]z$[1].barz $[1].bar.barz $[1].bar.bazz$[1].foorr)rrjrr)rrjrrjrrQ)rrjrrjrDr )rrjrr) rrr>rr(r{rr~rDr=r) r/rrrrrrrre5e6s rtest_multiple_nestingz0TestValidationErrorDetails.test_multiple_nesting~sq%!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)Nnodervrrchildrenrr^.*$rz#/definitions/node)rr)rr)rrQrjroot) definitionsrrQrjr_ab)rjrrvz$.root)rrr_) rjrrvrrjrrrrvz$.root.children.a)rrr_rr)rjrrvrrjrrrrvrrjrrrrvz$.root.children.a.children.ab) rrr>r(r}rrr~r)r/rrrrrrs rtest_recursivez)TestValidationErrorDetails.test_recursives (%+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) Nrrrrrr'rrrrrrr rrr>rr(r{rr~rr/rrrrrrs rtest_additionalPropertiesz4TestValidationErrorDetails.test_additionalProperties s +(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) NrErrrrrrr'rrrrrrs rtest_patternPropertiesz1TestValidationErrorDetails.test_patternProperties1sQ' )!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) NrrErr'rrrr$[1]rrrrs rtest_additionalItemsz/TestValidationErrorDetails.test_additionalItemsGs1:(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)rrrErr'rrrErrz$[2]rrrrs rtest_additionalItems_with_itemsz:TestValidationErrorDetails.test_additionalItems_with_items[s$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'}rx rrr>r(rrr{rr~rD)r/rrrerrors rtest_propertyNamesz-TestValidationErrorDetails.test_propertyNamesos2;!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 expectedrxrrr/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)relserrrxrrrs r test_if_elsez'TestValidationErrorDetails.test_if_elserr1c 2tjd}|jd\}|j|j|j |j |j|j|j|jfdddddtgdfy)NFrzFalse schema does not allow 12rx) rrr>r(rrrCrrrDr~r)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(rrrCrr}rrDr~r)r/refrrrs rtest_refz#TestValidationErrorDetails.test_refs"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)Nr)rrrrNr&rrEr)r)rrrz"5 is greater than the maximum of 3r')r)rNr$[3] rrr>r(rrrCrr}rrDr~r)r/rr type_error min_errors rtest_prefixItemsz+TestValidationErrorDetails.test_prefixItemss[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)Nrrr()rrrr>rDz2 is not of type 'string'rrErrz4 is not of type 'string'r>rNrrr/rrrrs rr*z6TestValidationErrorDetails.test_prefixItems_with_itemssEh'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. rrrrE)rrrr>rDrrFr@rrxNrrs rrGz1TestValidationErrorDetails.test_contains_too_many:s &x0C33F; &&'JK  %%## !! M3b $h/Bzl#  r1c ~ddidd}tj|}|jgd\}|j|j|j |j |j|j|j|j|jfdddgdtgddiddtdgd fy) Nrrrr9)rrr>r;r:rrxrrs rr<z0TestValidationErrorDetails.test_contains_too_fewYs%x0C33F; &&}5  %%## !! ?b $h/Bzl#  r1c ddidd}tj|}|jddg\}|j|j|j |j |j|j|j|j|jfddddiddgtgddiddtdgdfy) Nrrrr9r>z7[2, 4] does not contain items matching the given schemarrxrrs rtest_contains_nonez-TestValidationErrorDetails.test_contains_nonews%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) NrrQrapropz #/$defs/foorD)rrQ)rrjz'bar' is a required property)rjrrQz$.apropz'baz' is a required property)rrr>r(rrrCrr}rrDrr~rrs rtest_ref_siblingz+TestValidationErrorDetails.test_ref_siblingsj5'23)!& 33F; &&}5B   ""    ''  /wi eW%9:9:  0   ""    ''  /wi &UG<9:9:  r1N)rWrrXrrrrrrrrrrrrrrrr*rGr<rrrr1rrtrtstC-JK%Z%/N;/zcHJ2"2,2(2(M F F 2 >/ b2 h > < 6< r1rtc0eZdZdZdZdZdZdZdZy)MetaSchemaTestsMixinc|jtj5|jj ddidddy#1swYyxYw)Nrjrrrrr-rr.s rtest_invalid_propertiesz,MetaSchemaTestsMixin.test_invalid_propertiess9   z55 6 NN ' 'r(: ;7 6 6 AAc|jtj5|jj ddidddy#1swYyxYw)Nr 1rr.s rtest_minItems_invalid_stringz1MetaSchemaTestsMixin.test_minItems_invalid_strings9   z55 6 NN ' 'S(9 :7 6 6rc:|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_arrayss| >>  & &  & &  "":#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_itemss >>  & &  & &  "":#9#9:++Vb"X,>?;: NN ' '"b(: ;;:s BBc|jtj5|jj ddidddy#1swYyxYw)Nr4 *notaregexrr.s rtest_schema_with_invalid_regexz3MetaSchemaTestsMixin.test_schema_with_invalid_regexs9   z55 6 NN ' 'L(A B7 6 6rcB|jjddidy)Nr4rr)r-rr.s r>test_schema_with_invalid_regex_with_disabled_format_validationzSMetaSchemaTestsMixin.test_schema_with_invalid_regex_with_disabled_format_validations$ ##  % $ r1N) rWrrXrrrrrrrr1rrrs!<; 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.9sIr1)factoryrdefaultN)rWrrXrr_barrr1rOhNor 7s$56R(r1rNr)rrrrr) assertWarnsDeprecationWarningr r-r(rrr)r/rrrs rtest_evolve_with_subclassz,ValidatorTestMixin.test_evolve_with_subclass,s  0 1  )t~~ ) )2 $   2vy&9: ), 2&2 1s B44B=cd|j|jijddy)Nrr)rr-rr.s r#test_is_type_is_true_for_valid_typez6ValidatorTestMixin.test_is_type_is_true_for_valid_typeCs$ r*225(CDr1cd|j|jijddy)Nrrrr-rr.s r&test_is_type_is_false_for_invalid_typez9ValidatorTestMixin.test_is_type_is_false_for_invalid_typeFs& +33E7CDr1c|j|jijdd|j|jijddy)NTrrrr.s r,test_is_type_evades_bool_inheriting_from_intz?ValidatorTestMixin.test_is_type_evades_bool_inheriting_from_intIsJ +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) isinstanceintfloatrboolrrs rruzGValidatorTestMixin.test_it_can_validate_with_decimals..Ss,zC0((2$UD11(2r1r&rEg?rrT) rrr-r6redefinerrr(r>r)r/rr-rrrs r"test_it_can_validate_with_decimalsz5ValidatorTestMixin.test_it_can_validate_with_decimalsMsFH-.%% NN44==2 f% AsGAJ$;<="b$- )2)>)>w)G H)GU^^)G 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_aboutbs1NN x #  6"r1c\|ji}|j|jyr3)r-ryrr(s r,test_it_does_not_validate_formats_by_defaultz?ValidatorTestMixin.test_it_does_not_validate_formats_by_defaulths$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 r0r/s rcheckzTValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provided..checkps/%  HUG+ABCr1r rr/r0) r ValueErrorrr-rrrrr exceptioncause)r/rr1rcmr0s` @r2test_it_validates_formats_if_a_checker_is_providedzEValidatorTestMixin.test_it_validates_formats_if_a_checker_is_providedls/  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|tSr3rrr!s rruz@ValidatorTestMixin.test_non_string_custom_type..s z%'=r1r"r)rrrr-r6r#r)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)rtupler!s rruzNValidatorTestMixin.test_it_properly_formats_tuples_in_errors..s z%'?r1r" uniqueItemsT)rErENz(1, 1) has non-unique elements) rrr-r6r#rrrrrzstrr3)r/TupleValidatorrs r)test_it_properly_formats_tuples_in_errorsz.sJe}5r1c(t|tfSr3)rr*)rrrEs rruzBValidatorTestMixin.test_check_redefined_sequence..sZi06r1)rrr")r_NrrpTFrr_)r_rZr_N) rrrr-r6 redefine_manyrrrrr)r/rr-rvalid_instancesrinvalid_instancesrEs @rtest_check_redefined_sequencez0ValidatorTestMixin.test_check_redefined_sequencesD"$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)rrr-rrrr)r/rs r.test_it_creates_a_ref_resolver_if_not_providedzAValidatorTestMixin.test_it_creates_a_ref_resolver_if_not_providedsI   0 1~~b)22H2 h (?(?@2 1s 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_RefResolverssl#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.resolvings"  i0y))sN)rWrrXrrYr.srLegacyRefResolverrTs  * *r1rZrrVrN)rrrr-r)r/rZrrs` r@test_it_upconverts_from_yet_older_deprecated_legacy_RefResolverszSValidatorTestMixin.test_it_upconverts_from_yet_older_deprecated_legacy_RefResolverss\  * * %&)$   z99 : NN6HN 5 > >t D; : :s #A$$A-N)rWrrXrrrrrrrrrr$r)r+r6r<rCrKrMrQr[rr1rrr smGCDI+('.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-rrzrAr3r/rs rtest_True_is_not_a_schemaz-AntiDraft6LeakMixin.test_True_is_not_a_schemasP   z55 6! NN ' ' -7 +S-=>7 6 A**A3c|jtj5}|jj dddd|j dt jy#1swY/xYw)NFzFalse is not of typer_r`s rtest_False_is_not_a_schemaz.AntiDraft6LeakMixin.test_False_is_not_a_schema sP   z55 6! NN ' ' .7 ,c!++.>?7 6rbc|jt5}|jdjdddd|j j t jy#1swY4xYw)NTrr Exceptionr-rassertNotIsInstancer3rrr`s r5test_True_is_not_a_schema_even_if_you_forget_to_checkzIAntiDraft6LeakMixin.test_True_is_not_a_schema_even_if_you_forget_to_checksQ   y )Q NN4 ) )" -*   j.H.HI* ) !A**A3c|jt5}|jdjdddd|j j t jy#1swY4xYw)NFrrfr`s r6test_False_is_not_a_schema_even_if_you_forget_to_checkzJAntiDraft6LeakMixin.test_False_is_not_a_schema_even_if_you_forget_to_checksQ   y )Q NN5 ! * *2 .*   j.H.HI* )rjN)rWrrX__doc__rardrirlrr1rr]r]s? @ J Jr1r]c\eZdZUejZiifZded<ddidfZdZ dZ dZ d Z y ) TestDraft3Validatortuple[dict, dict]rrrrc\|jddi}|jtyNrany)r-rrr(s r#test_any_type_is_valid_for_type_anyz7TestDraft3Validator.test_any_type_is_valid_for_type_any"s$NNFE?3 68$r1cPtj|j|jjj dd}|ddi}|j d|j tj5|j ddddy#1swYyxYw)z( Sigh, because why not. rsc"t|tSr3r9r!s rruzBTestDraft3Validator.test_any_type_is_redefinable..-s j.Dr1r"rrrN) rrr-r6r#rrrr)r/r;rs rtest_any_type_is_redefinablez0TestDraft3Validator.test_any_type_is_redefinable&s!! NN44==D  65/* 2   z99 :   u %; : :s BB%cv|j|jddijtyrr)rr-rrr.s r!test_is_type_is_true_for_any_typez5TestDraft3Validator.test_is_type_is_true_for_any_type5s( 7@@JKr1c|j|jijdd|j|jddijdy)NTrrrs)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_tested8sH r*224CD 7@@FGr1N) rWrrXrrr-r__annotations__rrtrwryr{rr1rrorosA**I "BxE 'y!5(G% &LHr1rocDeZdZUejZiifZded<ddidfZy)TestDraft4ValidatorrprrrrN) rWrrXrrr-rr|rrr1rr~r~=+**I "BxE 'y!5(Gr1r~cDeZdZUejZiifZded<ddidfZy)TestDraft6ValidatorrprrrrN) rWrrXrrr-rr|rrr1rrrCrr1rcDeZdZUejZiifZded<ddidfZy)TestDraft7ValidatorrprrrrN) rWrrXrrr-rr|rrr1rrrIrr1rcDeZdZUejZiifZded<ddidfZy)TestDraft201909ValidatorrprrrrN) rWrrXrDraft201909Validatorr-rr|rrr1rrrO+//I "BxE 'y!5(Gr1rcDeZdZUejZiifZded<ddidfZy)TestDraft202012ValidatorrprrrrN) rWrrXrrr-rr|rrr1rrrUrr1rceZdZdZdZy)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_stored`sh#**2r#uF..vI   z99 :   t $; : :s A22A;N)rWrrXrmrrr1rrr[s %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_3k`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_4xrr1cddi}|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_Trues%  $ $T *  & & r1cj|jtjdtjyr rr.s r test_FalsezTestValidatorFor.test_Falses%  $ $U +  & & r1ctjddidd}ddi}|jtj||y)Nrirm12c&|jddSrorqrss rruz8TestValidatorFor.test_custom_validator..rvr1rwrrr,rrr/r-rs rtest_custom_validatorz&TestValidatorFor.test_custom_validatorsK%%/0+ -.  $ $V ,  r1ctjddid}ddi}|jtj||y)Nr$r13rSrrrs rtest_custom_validator_draft6z-TestValidatorFor.test_custom_validator_draft6sH%% 12 ./  $ $V ,  r1cj|jtjitjyr3rr.s r%test_validator_for_jsonschema_defaultz6TestValidatorFor.test_validator_for_jsonschema_defaults! j..r2J4N4NOr1cR|jtjiddy)Nr )rrrr.s r!test_validator_for_custom_defaultz2TestValidatorFor.test_validator_for_custom_defaults j..r4@$Gr1c|jt5}tjddiddd|j j t |j t|jdy#1swYOxYw)Nr unknownSchemarzThe metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.) rrrrr(filename__file__rAwarning)r/r5s r1test_warns_if_meta_schema_specified_was_not_foundzBTestValidatorFor.test_warns_if_meta_schema_specified_was_not_foundsh   0 1R  $ $Y,H I2 h/   O & 2 1s 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_unspecifiedsN  $ $D 1Q  ! !( +  $ $B ;2 2 1s -AA'clddit}}|jtj|||y)Nrzmailto:foo@example.com)rrrr)r/rr s r-test_validator_for_custom_default_with_schemaz>TestValidatorFor.test_validator_for_custom_default_with_schemas.$&>? j..vw?Ir1N)rWrrXrrrrrrrrrrrrrrrrr1rrrjsP                 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.assertUsessS ZZ  y.&-- H   F +I &*I Hs A!!A*c|jdditj|jdditjy)Nrrrr-r)rrrr.s rtest_draft3_validator_is_chosenz,TestValidate.test_draft3_validator_is_chosenJ 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_chosen!rr1c|jdditj|jdditjy)Nrrrrrrrr.s r$test_draft202012_validator_is_chosenz1TestValidate.test_draft202012_validator_is_chosen,sR J!55   I!55  r1cF|jitjy)Nrrr.s r)test_draft202012_validator_is_the_defaultz6TestValidate.test_draft202012_validator_is_the_default;s rZ-L-LMr1c|jtj5}tjdddiddd|j t jdy#1swY/xYw)Nrrrz1(?s)Failed validating '.*' in schema.*On instance)rrrrr assertRegexrAr3r`s rtest_validation_error_messagez*TestValidate.test_validation_error_message>sX   z99 :a   VX$6 7;    ? ; : A''A0c|jtj5}tjdddiddd|j t jdy#1swY/xYw)Nrrz3(?s)Failed validating '.*' in metaschema.*On schema)rrrrrrrAr3r`s rtest_schema_error_messagez&TestValidate.test_schema_error_messageFsW   z55 6!   VRL 17    A 7 6rcddddddigi}|jtj5}tjd|ddd|j dt jy#1swY/xYw) Nr_rrwrrrrz!12 is less than the minimum of 20)rrrrrrzrAr3)r/rrs rtest_it_uses_best_matchz$TestValidate.test_it_uses_best_matchNso !b1!    z99 :a   F +; 93q{{;KL; :s A00A9N) rWrrXrrrrrrrrrrrr1rrrs6+          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..validatejs1 .##R= . clln-s %Ar)Thread)targetF) threadingrstartjoinr(is_alive)r/rrthreadrs @r&test_validation_across_a_second_threadz4TestThreading.test_validation_across_a_second_threadgsS .  $x(   &//+V4ubkBr1N)rWrrXrmrrr1rrrZs  Cr1rceZdZdZdZy)TestReferencingcd}tj|}ddi}tj||}|j |j d|j dfdy) Nc0tjddiS)Nrr)rcreate_resource)uris rretrievez=TestReferencing.test_registry_with_retrieve..retrieve{s.. /BC Cr1)rrhttps://example.com/registryrr)TF) referencingRegistryrrr(r)r/rrrrs rtest_registry_with_retrievez+TestReferencing.test_registry_with_retrievezsf D'':0133FXN      #Y%7%7%> ?  r1ctj}ddi}tj||}t j d5}t j d|jtjj5|jddddddd|jy#1swY#xYw#1swY'xYw)NrrrTrrr) rrrrrrrrr Unresolvablerr)r/rrrrs r;test_custom_registries_do_not_autoretrieve_remote_resourceszKTestReferencing.test_custom_registries_do_not_autoretrieve_remote_resourcess'')0133FXN  $ $D 1Q  ! !( +"";#9#9#F#FG""2&H2 HG2 1s$?CB9C9C >CCN)rWrrXrrrr1rrrys    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.setUpsD 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_networks((44T: ZZ  t}}.> ?7((-.@ :#=#=#I#IJ (.-@ ?s$C$B<&C<C CCcd}dti|jd<|jj|5}|j ||jdddddy#1swYyxYw)Nz#/properties/foorrj)rr rrYr()r/rrs rtest_it_resolves_local_refsz+TestRefResolver.test_it_resolves_local_refssZ ',fh&7 l# ]] $ $S )X   Xt}}\'B5'I J* ) )s #A##A,cBdddid}tjj|d}|jd5}|j ||dddd|jd 5}|j ||ddddy#1swY9xYw#1swYyxYw) Nzhttp://bar/schema#rr)rir_c&|jddSrorqrs rruzETestRefResolver.test_it_resolves_local_refs_with_id..D"!5r1rxz#/ar_zhttp://bar/schema#/a)rr from_schemarYr(r/rrrs r#test_it_resolves_local_refs_with_idz3TestRefResolver.test_it_resolves_local_refs_with_ids,E5>B**66 57    &(   Xvc{ 3'    6 78   Xvc{ 38 7' & 7 7sB *B BBcj|jj|j5}|j||jdddddi|jj d<|jjd5}|j |ddddy#1swY[xYw#1swYyxYw)Nrr cached_refzcached_ref#/foo)rrYrrrrr()r/rs rtest_it_retrieves_stored_refsz-TestRefResolver.test_it_retrieves_stored_refss ]] $ $T__ 5 MM(D$6$6 76.3BK L) ]] $ $%6 78   Xr *8 7 6 58 7sBB)B&)B2cld}ddi}dtjvr<|jtjjdtjdt d|itjd<|j j |5}|j|ddddy#1swYyxYw)Nhttp://bar#bazrDrrequests http://bar)rmodulesr' __setitem__ReallyFakeRequestsrrYr()r/rrrs r,test_it_retrieves_unstored_refs_via_requestsz.fake_urlopens6   S, /$**V,33F;< .rr1rrp#zfoo#rrrr(rresolution_scoperYrs r.test_it_can_construct_a_base_uri_from_a_schemaz>TestRefResolver.test_it_can_construct_a_base_uri_from_a_schemas**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)NrprCrDrs r9test_it_can_construct_a_base_uri_from_a_schema_without_idzITestRefResolver.test_it_can_construct_a_base_uri_from_a_schema_without_ids**66v> **B/ 22B7    #x   Xv .$    $   Xv .% $$ # $ $s+B3B?3B<?Ccfd}ddidtjdid|i}|j5}j|dddy#1swYyxYw)Nc,j|Sr3rW)r1rrr/s rhandlerz@TestRefResolver.test_custom_uri_scheme_handlers..handler s   S# &Mr1rr foo://barrphandlers)rrrYr()r/rKrrrrs` @@rtest_custom_uri_scheme_handlersz/TestRefResolver.test_custom_uri_scheme_handlers s] **2rUG.handler s3 A||~% A ?@ A 00rLrpTr cache_remoterNrrrrYr/rKrrrUs` @rtest_cache_remote_onz$TestRefResolver.test_cache_remote_on sxH: 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% sUH: 3 ** %1A    $ % $ $s A  Actdfd}d}tjdid|i}|jtj 5}|j |5|jddddddd|jjt j y#1swYAxYw#1swYExYw)NzOh no! What's this?cr3r)r1rs rrKzTTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error..handler8 sKr1rLrprrMzShouldn't get this far!) r2rrrr_RefResolutionErrorrYr r(r3)r/rKrrerrrs @r3test_if_you_give_it_junk_you_get_a_resolution_errorzCTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error5 s01 **2rUG###C( 34)?  (F(Fu(MN)(? >s$ B=B11B=1B: 6B==Cc"tjdi}|j|jtj 5}|jddd|j dtjy#1swY/xYw)NrpzFailed to pop the scope) rr pop_scoperrrarzrAr3)r/rexcs r.test_helpful_error_message_on_failed_pop_scopez>TestRefResolver.test_helpful_error_message_on_failed_pop_scopeB sh**2r2   z== >#    ? /S]]1CD? >s BBctjj}tjd|}tj||}|j |j ddiddtjjdigi}tjd|}tj||}|j |j ddiy) z See #1085. rprr0rallOfrr$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/rprr-rrs` r.test_newly_created_validator_with_ref_resolverz>TestRefResolver.test_newly_created_validator_with_ref_resolverY s  '**2rVV.key sJ"ZZ (ZSVZ (".. /.SV. /  ( /s AA )rz)sorted)rrzs rrr s &c ""r1ceZdZUded<dZy)r)zdict[str, Any] _responsesc|jj|}|tdt|zt t j |S)Nz Unknown URL: )r}rrr2r\_ReallyFakeJSONResponser.r/)r/r1rUs rrrzReallyFakeRequests.get sC??&&s+ ;_tCy89 9&tzz(';<rs")%#' .1 L6(L6^MC(MC` L  L  ^5 5 pwE-wEtJJ4H-/A8H@)-/A8) ),h) ),h) )18) )18) %( %LJxLJ^^M8^MBCHC>h4l hl `#===***r1