rc&ddlmZddlmZmZddlmZddlmZddl m Z ddl m Z m Z ddlmZddlZddlZddlZddlZddl Z ddlZddlZdd lmZmZmZmZmZdd lmZd ZGd d e ZGdde Z Gdde Z!Gdde"Z#Gdde#e"Z$Gdde"Z%Gdde%e$e Z&Gdde%e$e Z'Gdde$e Z(Gdde$e Z)Gd d!e$e Z*Gd"d#e$e Z+Gd$d%e Z,Gd&d'e Z-Gd(d)e Z.d*Z/ej0Gd+d,e"Z1ej0Gd-d.e"Z2dS)/) annotations)deque namedtuple)contextmanager)Decimal)BytesIO)TestCasemock) pathname2urlN) FormatChecker TypeChecker exceptions protocols validators)bugc#fK|D]+}|ddtjdi|V,dS)NmessagezYou told me to fail!) setdefaultrValidationError) validatorerrorsinstanceschemaeachs B/usr/lib/python3/dist-packages/jsonschema/tests/test_validators.pyfailrsT11  #9:::(00400000011cteZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdS)TestCreateAndExtendc*||jtjt tjddi|_dt i|_t|_tj |j|j|j|_ dS)N$idzsome://meta/schemar) meta_schemar type_checker) addCleanup assertEqualr _META_SCHEMASdictr#rr r$create Validatorselfs rsetUpzTestCreateAndExtend.setUp#s     $ ) * *   "#78!4.'MM#*(*   rc||jj|jj|jjf|j|j|jfdSN)r&r* VALIDATORS META_SCHEMA TYPE_CHECKERrr#r$r+s r test_attrszTestCreateAndExtend.test_attrs3sY )*+   ! rcjdgi}|||j|dS)Nr)r&r*rr,rs r test_initzTestCreateAndExtend.test_init@s6" //6?????rcdgi}||}t|d}||gdS)Nrhello)r*list iter_errorsr&r,rrrs rtest_iter_errors_successfulz/TestCreateAndExtend.test_iter_errors_successfulDsS"NN6** i++G4455 $$$$$rc dddigi}||}tjdd|dddigtdg}t |d}|t|d||d|dS)NrrzWhoops!goodbye)rrrvalidator_value schema_pathr) r*rrrr9r:r&len _contents)r,rrexpected_errorrs rtest_iter_errors_one_errorz.TestCreateAndExtend.test_iter_errors_one_errorKsIy123NN6** #3 '34vh    i++I6677 Va((( ,,..0H0H0J0JKKKKKrcdddidddddigi}||}t|d}|t |d dS) NrrFirstzSecond!asdf)rrThirdr>)r*r9r:r&rBr;s r test_iter_errors_multiple_errorsz4TestCreateAndExtend.test_iter_errors_multiple_errors\s| G$%F;;G$ NN6** i++I6677 Va(((((rctjddid}|tjjd||jd||jddS)Nr" something my versionr#versionMyVersionValidator)rr)r%r'popr&__name__ __qualname__r,r*s r.test_if_a_version_is_provided_it_is_registeredzBTestCreateAndExtend.test_if_a_version_is_provided_it_is_registeredisz% ,      04kBBB +-ABBB /1EFFFFFrctjddid}|tjjd|t |iddS)Nr"rMrNrOz2MyVersionValidator(schema={}, format_checker=None))rr)r%r'rRr&reprrUs r test_reprzTestCreateAndExtend.test_reprrsx% ,      04kBBB  2   @     rc tjddid}|tjjd|t |dttdiddS)Nr"rMrNrOaizNMyVersionValidator(schema={'a': [0, 1, 2, 3, 4, 5, ...]}, format_checker=None)) rr)r%r'rRr&rXr9rangerUs rtest_long_reprz"TestCreateAndExtend.test_long_repr}s% ,      04kBBB  CeDkk!2!2344 5 5'     rctji}|t|iddS)Nr#z)Validator(schema={}, format_checker=None))rr)r&rXrUs rtest_repr_no_versionz(TestCreateAndExtend.test_repr_no_versionsM%"555   2   7     rctjddid}|tjjd||jddS)Nr"rMzfoo-barrOFooBarValidator)rr)r%r'rRr&rTrUs r-test_dashes_are_stripped_from_validator_nameszATestCreateAndExtend.test_dashes_are_stripped_from_validator_namess`% ,     04kBBB /1BCCCCCrcttj}tjddi|tj|dS)Nidr_)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_registeredsI 011tTl3333 18<<<<zMTestCreateAndExtend.test_validates_registers_meta_schema_id..AEE$OOrr#rPid_ofrr)r%r'rRassertInr,meta_schema_keymy_meta_schemas r'test_validates_registers_meta_schema_idz;TestCreateAndExtend.test_validates_registers_meta_schema_idsp*0& ++     04oFFF oz'?@@@@@rcd}d|i}tj|d|tjj|||tjdS)Nmeta schema $idr"rNrOrurws r.test_validates_registers_meta_schema_draft6_idzBTestCreateAndExtend.test_validates_registers_meta_schema_draft6_idsj+1&       04oFFF oz'?@@@@@rc tjid|tfddgfddddd ifd fDdS) Nr)r#rc3^K|]'\}}i||V(dS))rtypeN)is_type).0rrr*s r z@TestCreateAndExtend.test_create_default_types..sV  "D( " %%xd%CC      rarray)booleanT)integer )nullN)numberg(@object)stringfoo)rr) assertTrueallrUs @rtest_create_default_typesz-TestCreateAndExtend.test_create_default_typess%"DDD       bM%#"$rN%'      rcBt|jj}t}t j|jd|i}||j|j|j|jjft|||jj|jj|fdS)Nnew)r)r) r(r*r0rrextendr&r1r2)r,rfrExtendeds r test_extendzTestCreateAndExtend.test_extends122hh$ Ns|    #$%)   X3'''*+  rcDfd}d}d|d}tj|jj|}||j|tj|}||j|dS)zK Extending a validator preserves its notion of schema IDs. c`|dj|S)N__test__)rnr*ID_OF)rr,s rrtz3TestCreateAndExtend.test_extend_idof..id_ofs'::j$.*>*>v*F*FGG Grzthe://correct/id/zthe://wrong/id/)r"r)r#rr$rtN)rr)r$r&rr1r)r,rt correct_idr#OriginalDeriveds` rtest_extend_idofz$TestCreateAndExtend.test_extend_idofs H H H H H( $"  $#*     (<==zJJJ#H-- w':;;ZHHHHHrN)rS __module__rTr-r3r6r<rErKrVrYr]r`rcrgrzr}rrrrrrr r "s*      @@@%%%LLL" ) ) )GGG           DDD=== A A A A A A   "   ,IIIIIrr 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-S).TestValidationErrorMessagescf|dtj}||||g|Ri|}t ||}||d||t|dd||dj S)NclszNo errors were raised for )msgrAz"Expected exactly one error, found r) rRr_LATEST_VERSION check_schemar9r:rr&rBr)r,rrargskwargsrrrs r message_forz'TestValidationErrorMessages.message_forsjj :;;    C000000 i++H5566 $M$M$MNNN  KK ?V??    ay  rcd|dddi}||ddSNrArrrr1 is not of type 'string'rr&r,rs rtest_single_type_failurez4TestValidationErrorMessages.test_single_type_failures<""Avx6H"II "=>>>>>rcf|dddgi}||ddSrrrs rtest_single_type_list_failurez9TestValidationErrorMessages.test_single_type_list_failures>""Avz6J"KK "=>>>>>rcd}|ddt|i}||ddS)N)rrrArrz#1 is not of type 'string', 'object')rr9r&)r,typesrs rtest_multiple_type_failurez6TestValidationErrorMessages.test_multiple_type_failure sG"""AvtE{{6K"LL "GHHHHHrcddddgi}|d|tj}||ddS)NrFoorJ)nameminimumrArrrz1 is not of type 'Foo'rrDraft3Validatorr&r,rrs r#test_object_with_named_type_failurez?TestValidationErrorMessages.test_object_with_named_type_failures\Ea889:""*#   ":;;;;;rcd|dddi}||ddS)NrArrz1 is less than the minimum of 2rrs r test_minimumz(TestValidationErrorMessages.test_minimums;""Ay!n"EE "CDDDDDrcd|dddi}||ddS)NrAmaximumrrz"1 is greater than the maximum of 0rrs r test_maximumz(TestValidationErrorMessages.test_maximums;""Ay!n"EE "FGGGGGrcd\}}d||ii}|ddi|tj}||ddSNbarr dependenciesrrrz'foo' is a dependency of 'bar'rr,dependonrrs r test_dependencies_single_elementz22#   d5kk7+++ d5kk7+++ ('22222rclddi}|ddi|}|d|dS)Nconstrrrrz12 was expectedrrs r test_constz&TestValidationErrorMessages.test_constlsL2""U^#   '11111rcdddii}|digg|tj}||ddS)Ncontainsrrrrz4None of [2, {}, []] are valid under the given schema)rrDraft6Validatorr&rs rtest_contains_draft_6z1TestValidationErrorMessages.test_contains_draft_6tsfwm,""R[*#     B     rcTtd}|ddddi}|d||}|t d||t d||d|dS) Nr)formatsthingcdSNFr)values rrqzQTestValidationErrorMessages.test_invalid_format_default_message..serformatbla)rrformat_checkerzis not a)r checksrrvrX)r,checkerrrs r#test_invalid_format_default_messagez?TestValidationErrorMessages.test_invalid_format_default_messages+++w 3 3444G$"""#   d5kk7+++ d7mmW--- j'*****rc ddddiddidd}|ddi|tj }||d t dt d t d |dd d|tj }||dt dt dt d t d dS)NrFrr)^abc$^def$)rrpatternPropertieszebra{rz,{} does not match any of the regexes: {}, {}rri)rfishz.{}, {} do not match any of the regexes: {}, {}r)rrDraft4Validatorr&rrXrs r1test_additionalProperties_false_patternPropertieszMTestValidationErrorMessages.test_additionalProperties_false_patternPropertiess."*/ &1 &1(( ""s^*#     : A AW tG}}d7mm     """C00*#     < C CV d7mmT']]DMM       rc`|dd}||ddS)NrMFrz'False schema does not allow 'something'rrs rtest_False_schemaz-TestValidationErrorMessages.test_False_schemasA"" #   "KLLLLLrcd|dddi}||ddS)NrJ multipleOfrrz3 is not a multiple of 2rrs rtest_multipleOfz+TestValidationErrorMessages.test_multipleOfsF"" !$#   "<=====rcd|gddi}||ddS)NminItemsrrz[] is too shortrrs r test_minItemsz)TestValidationErrorMessages.test_minItemss;""B A"GG "344444rch|gdddi}||ddS)NrmaxItemsrrz[1, 2, 3] is too longrrs r test_maxItemsz)TestValidationErrorMessages.test_maxItemss?""IIIz1o"NN "9:::::rcn|gddiigd}||ddS)NrArrFr prefixItemsrz%Expected at most 2 items, but found 4rrs rtest_prefixItems_with_itemsz7TestValidationErrorMessages.test_prefixItems_with_itemssS""%%%"B8<<#   "IJJJJJrcd|dddi}||ddS)Nrl minLengthrrz'' is too shortrrs rtest_minLengthz*TestValidationErrorMessages.test_minLengthsF""##   "344444rcd|dddi}||ddS)Nabc maxLengthrrz'abc' is too longrrs rtest_maxLengthz*TestValidationErrorMessages.test_maxLengthsF""##   "566666rcd|dddi}||ddS)Nbbbpatternz^a*$rz'bbb' does not match '^a*$'rrs r test_patternz(TestValidationErrorMessages.test_patternsF""v&#   "?@@@@@rch|gdddii}||ddS)Nrrrrz3[] does not contain items matching the given schemarrs rtest_does_not_containz1TestValidationErrorMessages.test_does_not_containsV"" 23#     A     rcn|ddgddidd}||ddS) NrrArrrr minContainsrMToo few items match the given schema (expected at least 2 but only 1 matched)rrs rtest_contains_too_fewz1TestValidationErrorMessages.test_contains_too_fews_""QZ!' 21EE#     7     rcp|ddgddiddd}||d dS) NrrArrrrr! maxContainsrr"rrs r&test_contains_too_few_both_constrainedzBTestValidationErrorMessages.test_contains_too_few_both_constrainedsg""QZ#X.  #          rcn|gdddidd}||ddS)Nrrbazrrrrr'r:Too many items match the given schema (expected at most 2)rrs rtest_contains_too_manyz2TestValidationErrorMessages.test_contains_too_manys_""***!' 21EE#     H     rct|dgdzddiddd}||d dS) Nrrrrrr%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_constrained sg""Wq[#X.  #     H     rcd|dddi}||ddS)NrJexclusiveMinimumrrz+3 is less than or equal to the minimum of 5rrs rtest_exclusiveMinimumz1TestValidationErrorMessages.test_exclusiveMinimumsQ""&*#     9     rcd|dddi}||ddS)NrJexclusiveMaximumrrz.3 is greater than or equal to the maximum of 2rrs rtest_exclusiveMaximumz1TestValidationErrorMessages.test_exclusiveMaximum%sH""A7I16M"NN   <     rcf|iddgi}||ddS)Nrequiredrrz'foo' is a required propertyrrs r test_requiredz)TestValidationErrorMessages.test_required,s>""B UG7L"MM "@AAAAArcn|diidddgii}||ddS)NrdependentRequiredrrz'bar' is a dependency of 'foo'rrs rtest_dependentRequiredz2TestValidationErrorMessages.test_dependentRequired0sQ""R['%%)9:#   "BCCCCCrcd|iddi}||ddS)N minPropertiesrrz"{} does not have enough propertiesrrs rtest_minPropertiesz.TestValidationErrorMessages.test_minProperties7s<""B7K"LL "FGGGGGrcl|iiidddi}||ddS)N)r[bc maxPropertiesrrz3{'a': {}, 'b': {}, 'c': {}} has too many propertiesrrs rtest_maxPropertiesz.TestValidationErrorMessages.test_maxProperties;s[""BR00#Q'#     A     rcf|iddgi}||ddS)NoneOfFrz.{} is not valid under any of the given schemasrrs rtest_oneOf_matches_nonez3TestValidationErrorMessages.test_oneOf_matches_noneEsI""B%7I"JJ   <     rch|idddgi}||ddS)NrFTrz${} is valid under each of True, Truerrs rtest_oneOf_matches_too_manyz7TestValidationErrorMessages.test_oneOf_matches_too_manyLs@""B$7N"OO "HIIIIIrcnddd}|ddg|}||ddS)NrFrunevaluatedItemsrrrz@Unevaluated items are not allowed ('bar', 'foo' were unexpected)rrs rtest_unevaluated_itemsz2TestValidationErrorMessages.test_unevaluated_itemsPsQ!u==""UEN6"JJ  N     rcjddd}|d|}||ddS)NrFrKrrz'foo' is not of type 'array'rrs r&test_unevaluated_items_on_invalid_typezBTestValidationErrorMessages.test_unevaluated_items_on_invalid_typeXsD!u==""E&"AA "@AAAAArcpddd}|ddd|}||ddS) NrFrunevaluatedPropertiesrrrrrzEUnevaluated properties are not allowed ('bar', 'foo' were unexpected)rrs rtest_unevaluated_propertiesz7TestValidationErrorMessages.test_unevaluated_properties]sj"UCC"" #     -     rcjddd}|d|}||ddS)NrFrQrrz'foo' is not of type 'object'rrs r+test_unevaluated_properties_on_invalid_typezGTestValidationErrorMessages.test_unevaluated_properties_on_invalid_typelsD"UCC""E&"AA "ABBBBBrN)/rSrrTrrrrrrrrrrrrrrrrrrrrrrr rrrrrr#r(r.r0r3r6r9r<r?rDrGrIrMrOrTrVrrrrrs ! ! !??????III <<<EEEHHHDDD    DDDDDD555<<<999 3 3 3222     + + +   <MMM>>>555;;;KKK555777AAA                        BBBDDDHHH      JJJ   BBB    CCCCCrrceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdS)TestValidationErrorDetailsc d}dddiddigi}tj|}t||}|t |d|d}||jd||j|d||j|||j || |j ||j tg||jtg||jtg||jd ||jtdg||jtdg||jtdg|t |jd t+|j\}}||jd||j|ddd||j|||j |dd||j |||j tg||jtg||jtg||jd ||jtddg||jtddg||jtgd ||j||jd||j|ddd||j|||j |dd||j |||j tg||jtg||jtg||jd ||jtddg||jtddg||jtgd |t |jddS) NranyOfrrrrAr$r)rZrr)rZrAr)rrr9r:r&rBrr?rr assertIsNoneparentpathr relative_path absolute_path json_pathr@relative_schema_pathabsolute_schema_pathcontext sorted_errorsassertIs assertFalser,rrrree1e2s r test_anyOfz%TestValidationErrorDetails.test_anyOfus& B" .v66 i++H5566 Va((( 1I g... *F7O<<< X... 6*** !(### r+++ %))444 %))444 c*** wi(8(8999 /y1A1ABBB /y1A1ABBB QY+++qy))B y111 +VG_Q-? -JKKK h/// F7OA$6777 bi### %)),,, )599555 )599555 s+++ 9~)>)>??? 0%I2G2GHHH   #U+B+B+B%C%C    $$$ v... +VG_Q-?-GHHH h/// F7OA$6777 bi### %)),,, )599555 )599555 s+++ 6{););<<< 0%F 2D2DEEE 0%8L8L8L2M2MNNN RZ!,,,,,rc ddi}dddiddddgiidgi}tj|}t||}|t |d|d }||jd||j|d||j|||j || |j ||j tg||jtg||jtg||jd ||jtdg||jtdg||jtdg|t |jdt+|j\}}||jd||j|dd d||j|||j |dd ||j |||j tg||jtg||jtg||jd ||jtd dg||jtd dg||jtgd ||j||jd||jdg||jd||j ddgi||j |||j tdg||jtdg||jtdg||jd ||jtgd ||jtgd ||jtgd||jdS)NrrArrrenumrr propertiesrr\)rrr$.foo)rArqrro)rrArqrro)rrr9r:r&rBrr?rrr]r^r_rr`rarbr@rcrdrerfrgrhris r test_typez$TestValidationErrorDetails.test_types@1: #$#(6A3-"8 .v66 i++H5566 Va((( 1I f--- *F6N;;; X... 6*** !(### r+++ %))444 %))444 c*** vh888 /xAAA /xAAA QY+++qy))B v... +VF^A->v-FGGG h/// F6N1$5666 bi### %)),,, )599555 )599555 s+++ 6{););<<< 0%F 2D2DEEE 0%8K8K8K2L2LMMM $$$ v... +aS111 a((( VaSM222 bi### %..111 )5%>>::: )5%>>::: w///  NE"B"B"BCC      #U+K+K+K%L%L      # ::: ; ;   $$$$$rc:ddgddd}dddid did gd d d i}tj|}||}t|\}}}}||jt dg||jt dg||jt dg||jt dg||jt dg||jt dg||jt dg||jt dg||jt dg||jt dg||jt dg||jt dg||j d||j d||j d||j d||j d ||j d||j d||j ddS)NrrAspam)rrr+quuxrqrrr )rr%)rror*rr+r$.barz$.bazrrror) rrr:rfr&r_rr`rarbr) r,rrrrrkrle3e4s rtest_single_nestingz.TestValidationErrorDetails.test_single_nestingsaSVDD )"A#%|||<< .v66 &&x00&v..BB %..111 %..111 %..111 %..111 )5%>>::: )5%>>::: )5%>>::: )5%>>::: )5%>>::: )5%>>::: )5%>>::: )5%>>::: w/// w/// w/// w/// z222 v... y111 v.....rc@ddddgiddg}dddgddd gid d d id diddddd}tj|}||}t|\}}}}} } ||jt g||jt dg||jt ddg||jt gd|| jt gd|| jt ddg||jd||jd||jd||jd|| jd|| jd||jt dg||jt ddg|t|jgd|t|jgd|t| jgd |t| jgd!||j d||j d||j d||j d || j d || j ddS)"NrArr+rSrwrrrorJrr8Tr)rr+rp)rrrr)rArr)rArr+rr\$[0]z$[1].barz $[1].bar.barz $[1].bar.bazz$[1].foorr)rrqrr)rrqrrqrr8)rrqrrqr+r)rrqrro) rrr:rfr&r_rrbr@r9r) r,rrrrrkrlr|r}e5e6s rtest_multiple_nestingz0TestValidationErrorDetails.test_multiple_nesting.sq%!66?!8,"QF+ '$.#5$.?''      ".v66 &&x00!.v!6!6BBB %)),,, %**--- %E "3"3444 %(9(9(9":":;;; %(9(9(9":":;;; %E "3"3444 s+++ v... z222 ~666 ~666 z222 x999 /@)A)ABBB   "H"H"H      K K K      K K K      "H"H"H    v... v... v... z222 z222 v.....rc ~dddddgddiddd d iid d d giiddgdd d iid}dddddddiid id i}tj|}||\}||jt dg||jt gd||jd|j\}||jt gd||jt gd||jd|j\}||jt gd||jt gd||jddS)NnoderZrrchildrenrr^.*$$refz#/definitions/node)rr)rr)rr8rqroot) definitionsrr8rqr[ab)rqrrZz$.root)rrr[) rqrrZrrqrrrrZz$.root.children.a)rrr[rr)rqrrZrrqrrrrZrrqrrrrZz$.root.children.a.children.ab) rrr:r&rarrdrbre)r,rrrrjrkrls rtest_recursivez)TestValidationErrorDetails.test_recursiveksw (%+Z$8!'%)1$*(.0D-&6")) ' '*!F,@#AB1  8  # &#%     .v66  " "8 , , %//:::  "E*I*I*I$J$J    h///i )51J1J1J+K+KLLL   #U    & &    ':;;;j   e;;;     #U&&   * 'FGGGGGrcddd}ddddi}tj|}||}t|\}}||jt dg||jt dg||jd ||jd ||jd ||jd dS) Nrrrrrrrrrr{rrrr rrr:rfr&r_rrbrr,rrrrrkrls rtest_additionalPropertiesz4TestValidationErrorDetails.test_additionalPropertiess ++(9*K*KL.v66 &&x00v&&B %..111 %..111 w/// w/// v... y11111rcddd}dddiddidi}tj|}||}t|\}}||jt d g||jt d g||jd ||jd ||jd||jddS) NrArrrrrrrrrr{rrrrs rtest_patternPropertiesz1TestValidationErrorDetails.test_patternPropertiessQ'' )!1~"" .v66 &&x00v&&B %..111 %..111 w/// w/// v... y11111rcddg}gdddd}tj|}||}t|\}}||jt dg||jt dg||jd||jd ||jd ||jd dS) NrrArrrrrr$[1]rrrrs rtest_additionalItemsz/TestValidationErrorDetails.test_additionalItemss1:(1a@@   .v66 &&x00v&&B %**--- %**--- v... v... v... y11111rcgd}igdddd}tj|}||}t|\}}||jt dg||jt dg||jd||jd ||jd ||jd dS) N)rrrArrrrrArrz$[2]rrrrs rtest_additionalItems_with_itemsz:TestValidationErrorDetails.test_additionalItems_with_items s$$$T(1a@@   .v66 &&x00v&&B %**--- %**--- v... v... v... y11111rcddi}ddddiii}tj|}||\}||jd||jd||jtg||jd||j tddgdS)Nrr propertyNamesnotrz0'foo' should not be valid under {'const': 'foo'}r\ rrr:r&rrr_rrbr@)r,rrrerrors rtest_propertyNamesz-TestValidationErrorDetails.test_propertyNamess2;!EGU+;#<=.v66 &&x00 %000  M >    U2YY/// #... *E?E2J,K,KLLLLLrcddiddid}tj|}|d\}||jd||jd||jtg||jd||j tddgdS)Nrr )ifthen13 was expectedr\rrr,rrrs r test_if_thenz'TestValidationErrorDetails.test_if_then/B-bM   .v66 &&r** '222 (9::: U2YY/// #... *E672C,D,DEEEEErcddiddid}tj|}|d\}||jd||jd||jtg||jd||j tddgdS) Nrrr)relserurr\rrrs r test_if_elsez'TestValidationErrorDetails.test_if_else>rrc tjd}|d\}||j|j|j|j|j|j |j fdddddtgdfdS)NFrzFalse schema does not allow 12r\) rrr:r&rrr?rrr@rbr)r,rrs rtest_boolean_schema_Falsez4TestValidationErrorDetails.test_boolean_schema_FalseMs.u55 &&r**  % ! 1b       rc ddddii}}tjd|itjdi||i}|d d i\}||j|j|j|j|j |j |j |j fd ddd td gdditddgd fdS) NsomeRefrrrrrlstoreresolverr notAnIntegerz''notAnInteger' is not of type 'integer'rr)rr RefResolverr:r&rrr?rrarr@rbr)r,refrrrs rtest_refz#TestValidationErrorDetails.test_reffs"869:M!NV. SM+B3-HHH   &&~'>??  %# ! :ug#-v677      rc .dddiiiddigi}tj|}|gd\}}||j|j|j|j|j|j |j |j fddddtd gdditgd d f||j|j|j|j|j|j |j |j fd ddd tdgdditgddfdS)NrrrrrJr rrAr)rrrrz"5 is greater than the maximum of 3r)rrJr$[3] rDraft202012Validatorr:r&rrr?rrarr@rbr)r,rr type_error min_errors rtest_prefixItemsz+TestValidationErrorDetails.test_prefixItemssh68"4b"y!n!MN3F;; ) 5 56F6F6F G G I "$*#(!&$ ,qc "00011    , !#)"' %# 5qc A33344      rc &ddiigd}tj|}|gd\}}||j|j|j|j|j|j |j |j fddddtdgdditddgd f||j|j|j|j|j|j |j |j fd ddd td gdditddgd fdS)Nrrr)rrrr%r+z2 is not of type 'string'rrArrz4 is not of type 'string'r%rJrrr,rrrkrls rrz6TestValidationErrorDetails.test_prefixItems_with_itemssWh'4  3F;; &&'B'B'BCCB   "     ,qc "w'((    ,   "     ,qc "w'((      rc Nddidd}tj|}|gd\}||j|j|j|j|j|j |j |j fdddgdtgddiddtdgd fd S) z `contains` + `maxContains` produces only one error, even if there are many more incorrectly matching elements. rrrr,)rrrr%r+rwr-r'rr\Nrrs rr.z1TestValidationErrorDetails.test_contains_too_manys &x0CC3F;; &&'J'J'JKK  %# ! M333b $h/BBzl##      rc Nddidd}tj|}|gd\}||j|j|j|j|j|j |j |j fdddgdtgddiddtdgd fdS) Nrrrr )rrr%r"r!rr\rrs rr#z0TestValidationErrorDetails.test_contains_too_few s%x0CC3F;; &&}}}55  %# ! ? b $h/BBzl##      rc Rddidd}tj|}|ddg\}||j|j|j|j|j|j |j |j fddddiddgtgddiddtdgdfdS) Nrrrr r%z7[2, 4] does not contain items matching the given schemarr\rrs rtest_contains_nonez-TestValidationErrorDetails.test_contains_none's%x0CC3F;; &&1v..  %# ! J"Ab $h/BBzl##      rcdddgiidddgdid}tj|}|dii\}}||j|j|j|j|j|j |j |j |j f d ddgitdgddgitgd tgd d f ||j|j|j|j|j|j |j |j |j f d ddgitdgddgdtgd tgd d f dS) Nrr8rapropz #/$defs/foor+)rr8)z$defsrqz'bar' is a required property)rqrr8z$.apropz'baz' is a required property)rrr:r&rrr?rrarr@rcrbrrs rtest_ref_siblingz+TestValidationErrorDetails.test_ref_siblingBsj5'23)!&  3F;; &&}55B   "   '  /wi  eW%999::999::    0   "   '  /wi  &UG<<999::999::      rN)rSrrTrmrsr~rrrrrrrrrrrrrr.r#rrrrrrXrXrs\C-C-C-JK%K%K%Z%/%/%/N;/;/;/zcHcHcHJ222"222,222(222(MMM F F F F F F   2   >/ / / b2 2 2 h   >   <   6< < < < < rrXc&eZdZdZdZdZdZdS)MetaSchemaTestsMixinc|tj5|jddiddddS#1swxYwYdS)Nrqr assertRaisesr SchemaErrorr*rr+s rtest_invalid_propertiesz,MetaSchemaTestsMixin.test_invalid_propertiess   z5 6 6 < < N ' 'r(: ; ; ; < < < < < < < < < < < < < < < < < <A  AAc|tj5|jddiddddS#1swxYwYdS)Nr1rr+s rtest_minItems_invalid_stringz1MetaSchemaTestsMixin.test_minItems_invalid_strings   z5 6 6 ; ; N ' 'S(9 : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;rc>|jdgidS)zk Technically, all the spec says is they SHOULD have elements, not MUST. See #529. roNr*rr+s rtest_enum_allows_empty_arraysz2MetaSchemaTestsMixin.test_enum_allows_empty_arrayss$ ##VRL11111rcB|jdddgidS)zg Technically, all the spec says is they SHOULD be unique, not MUST. See #529. rorNrr+s r!test_enum_allows_non_unique_itemsz6MetaSchemaTestsMixin.test_enum_allows_non_unique_itemss) ##Vb"X$677777rN)rSrrTrrrrrrrrrsP<<<;;; 22288888rrceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdS)ValidatorTestMixincl||itjdSr/)assertIsInstancer*rr+s r)test_it_implements_the_validator_protocolz>68"4x>HH h''' C+++++rcDtjGdd|j}|id}||jgd|ddi}||jgd||jdd S) 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. cTeZdZejdZejdZdS):ValidatorTestMixin.test_evolve_with_subclass..OhNoc gdS)NrrrrrrqzCValidatorTestMixin.test_evolve_with_subclass..OhNo.s )))r)factory%defaultN)rSrrTattribr_barrrrOhNors:$'"3"3444C472&&&DDDrrr)rrrrrN)rrpr*r&rrr)r,rrrs rtest_evolve_with_subclassz,ValidatorTestMixin.test_evolve_with_subclasss  ' ' ' ' '4> ' '  'D$$$   222vy&9:: ))),,, 2&&&&&rcGfddt}|}ddi}tj5||dddddS#1swxYwYdS)zb Legacy RefResolvers support only the context manager form of resolution. c*eZdZefdZdS)XValidatorTestMixin.test_it_delegates_to_a_legacy_ref_resolver..LegacyRefResolverc3DK|dddiVdS)Nthe refrrr&)thisrr,s r resolvingzbValidatorTestMixin.test_it_delegates_to_a_legacy_ref_resolver..LegacyRefResolver.resolvings4  i000y))))))rN)rSrrTrrr+srLegacyRefResolverrs8  * * * *^ * * *rrrrrN)rrrrr*r)r,rrrs` r*test_it_delegates_to_a_legacy_ref_resolverz=ValidatorTestMixin.test_it_delegates_to_a_legacy_ref_resolvers  * * * * * * * * * * %$&&)$   z9 : : E E NN6HN 5 5 > >t D D D E E E E E E E E E E E E E E E E E Es+A<<BBc~||idddS)Nrr)rr*rr+s r#test_is_type_is_true_for_valid_typez6ValidatorTestMixin.test_is_type_is_true_for_valid_types6 r**225(CCDDDDDrc~||idddS)Nrrrhr*rr+s r&test_is_type_is_false_for_invalid_typez9ValidatorTestMixin.test_is_type_is_false_for_invalid_types8 ++33E7CCDDDDDrc||idd||idddS)NTrrr r+s r,test_is_type_evades_bool_inheriting_from_intz?ValidatorTestMixin.test_is_type_evades_bool_inheriting_from_intsh ++33D)DDEEE ++33D(CCDDDDDrczdddii}tj|j|jjdd}||}|ddt dt dz gd igd dg}|d ||D|dS) Nrrrcrt|tttfot|t Sr/) isinstanceintfloatrboolrrs rrqzGValidatorTestMixin.test_it_can_validate_with_decimals..s4zC0(((2$UD111rr$rAg?rzrTcg|] }|j Srr)rrs r zIValidatorTestMixin.test_it_can_validate_with_decimals.. s H H HU^ H H Hr) rrr*r2redefinerrr&r:)r,rr*rrs r"test_it_can_validate_with_decimalsz5ValidatorTestMixin.test_it_can_validate_with_decimalssFH-.% N4==22   If%% AsGAJJ$;<==="b$-  H H)>)>w)G)G H H H      rcz|ddit}|ddS)Nrcarrotrbugs)r*r rr,rs r7test_it_returns_true_for_formats_it_does_not_know_aboutzJValidatorTestMixin.test_it_returns_true_for_formats_it_does_not_know_about sDNN x #   6"""""rcd|i}||jdSr/)r*r]rr s r,test_it_does_not_validate_formats_by_defaultz?ValidatorTestMixin.test_it_does_not_validate_formats_by_defaults0NN2&&  )233333rct}td|dtfd}ddi|}|dt j5}|ddddn #1swxYwY|j j dS) NzBad!r)raisescx|dkrdS|dkrd|dS)NgoodTbadz What is {}? [Baby Don't Hurt Me])rr)rr(r,s rcheckzTValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provided..checksFt%  <CCEJJKKKKKrrrr'r() r ValueErrorrr*rrrrrg exceptioncause)r,rr)rcmr(s` @r2test_it_validates_formats_if_a_checker_is_providedzEValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provideds1//   j 1 1 L L L L L 2 1 LNN u g#   6"""   z9 : : &b   u % % % & & & & & & & & & & & & & & & bl(#.....sB77B;>B;ct}d|gi}tj|j|jj|d}||ddS)Nrc,t|tSr/rrrs rrqz@ValidatorTestMixin.test_non_string_custom_type..6sz%'='=rrru)rrrr*r2rr)r,non_string_typerCrazys rtest_non_string_custom_typez.ValidatorTestMixin.test_non_string_custom_type/sy ((?+,! N4====    f r"""""rcxtj|j|jjdd}|t j5}|ddiddddn #1swxYwY| dt|j dS) zh A tuple instance properly formats validation errors for uniqueItems. See #224 rc,t|tSr/)rtuplers rrqzNValidatorTestMixin.test_it_properly_formats_tuples_in_errors..Esz%'?'?rr uniqueItemsT)rArANz(1, 1) has non-unique elements) rrr*r2rrrrrrvstrr+)r,TupleValidatorrjs r)test_it_properly_formats_tuples_in_errorsz.VsJe}55rc2t|tfSr/)rr()rrr=s rrqzBValidatorTestMixin.test_check_redefined_sequence..YsZi066r)rrr)r[NrrlTFrr[)r[rAr[N) rrrr*r2 redefine_manyrrrrr)r,rr*rvalid_instancesrinvalid_instancesr=s @rtest_check_redefined_sequencez0ValidatorTestMixin.test_check_redefined_sequenceLs"$77{F33 % N4BB       If%%  ,,, - - E7QC. ! ! E7^^UA3ZZ (UGnn qc | ,w !" #s ~&6%7 8 E5'NN# $ $eUA3ZZL&9&9 : YsA   #u 5 5 6 #qc |,, #ug/00   # #uaSzz : :;<< # #ueW~~ > >?@@ 5w(( ) )5uaSzz1B1B+C+C D! &( ) )H   x ( ( ( ( /// " " E7UG$ % % E7^^UE7^^ ,UGnn ug/ 0w !" #w(8'9&:%; < E5'NN# $ $eUE7^^,<&=&= > YsE " "IIc5$9$9 : #ug/00 #ug/00   # #ueW~~ > >?@@ # #ueW~~ > >?@@ 5w(( ) )5ueW~~1F1F+G+G H! &* - -H"":#=>> - -""8,,, - - - - - - - - - - - - - - - - -s:PP #P N)rSrrTrrrrrrrrrr r rrr!r#r.r4r;rCrrrrrsQGGGCCCDDDIII   %%% , , ,''',EEE$EEEEEEEEE   *### 444///0 # # #JJJ"@-@-@-@-@-rrceZdZdZdZdZejeddZ ejeddZ dS)AntiDraft6LeakMixinzN Make sure functionality from draft 6 doesn't leak backwards in time. c|tj5}|jddddn #1swxYwY|dt |jdS)NTzTrue is not of typerrrr*rrvr9r+r,rjs rtest_True_is_not_a_schemaz-AntiDraft6LeakMixin.test_True_is_not_a_schemas   z5 6 6 .! N ' ' - - - . . . . . . . . . . . . . . . +S-=-=>>>>>AA A c|tj5}|jddddn #1swxYwY|dt |jdS)NFzFalse is not of typerGrHs rtest_False_is_not_a_schemaz.AntiDraft6LeakMixin.test_False_is_not_a_schemas   z5 6 6 /! N ' ' . . . / / / / / / / / / / / / / / / ,c!+.>.>?????rJi c2tjdi}|t5}|d|ddddn #1swxYwY||jtj dS)NrlTrr rrr Exceptionr*rassertNotIsInstancer+rrr,rrjs r5test_True_is_not_a_schema_even_if_you_forget_to_checkzIAntiDraft6LeakMixin.test_True_is_not_a_schema_even_if_you_forget_to_checks)"b11   y ) ) AQ NN4(N 3 3 < .sj.D.DrrrrrN) rrr*r2rrrrr)r,r3rs rtest_any_type_is_redefinablez0TestDraft3Validator.test_any_type_is_redefinables! N4==DD    E65/** 2   z9 : : & &   u % % % & & & & & & & & & & & & & & & & & &s<BB#&B#c||dditdSr])rr*rrr+s r!test_is_type_is_true_for_any_typez5TestDraft3Validator.test_is_type_is_true_for_any_types< 77@@JJKKKKKrc||idd||ddiddS)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_testedsf r**224CCDDD 77@@FFGGGGGrN) rSrrTrrr*r__annotations__rr_rbrdrfrrrrZrZs*I "BxE''''y!5(G%%% & & &LLLHHHHHrrZc<eZdZUejZiifZded<ddidfZdS)TestDraft4Validatorr[rrrrN) rSrrTrrr*rrgrrrrriri<*I "BxE''''y!5(GGGrric<eZdZUejZiifZded<ddidfZdS)TestDraft6Validatorr[rrrrN) rSrrTrrr*rrgrrrrrlrlrjrrlc<eZdZUejZiifZded<ddidfZdS)TestDraft7Validatorr[rrrrN) rSrrTrrr*rrgrrrrrnrnrjrrnc<eZdZUejZiifZded<ddidfZdS)TestDraft201909Validatorr[rrrrN) rSrrTrDraft201909Validatorr*rrgrrrrrprp</I "BxE''''y!5(GGGrrpc<eZdZUejZiifZded<ddidfZdS)TestDraft202012Validatorr[rrrrN) rSrrTrrr*rrgrrrrrtrtrrrrtcheZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdS)TestValidatorForcddi}|tj|tjddi}|tj|tjdS)N$schema&http://json-schema.org/draft-03/schema'http://json-schema.org/draft-03/schema#)rgr validator_forrr5s r test_draft_3zTestValidatorFor.test_draft_3xEF  $V , ,  &   FG  $V , ,  &     rcddi}|tj|tjddi}|tj|tjdS)Nrx&http://json-schema.org/draft-04/schema'http://json-schema.org/draft-04/schema#)rgrr{rr5s r test_draft_4zTestValidatorFor.test_draft_4r}rcddi}|tj|tjddi}|tj|tjdS)Nrx&http://json-schema.org/draft-06/schema'http://json-schema.org/draft-06/schema#)rgrr{rr5s r test_draft_6zTestValidatorFor.test_draft_6r}rcddi}|tj|tjddi}|tj|tjdS)Nrx&http://json-schema.org/draft-07/schema'http://json-schema.org/draft-07/schema#)rgrr{rr5s r test_draft_7zTestValidatorFor.test_draft_7r}rcddi}|tj|tjddi}|tj|tjdS)Nrxz,https://json-schema.org/draft/2019-09/schemaz-https://json-schema.org/draft/2019-09/schema#)rgrr{rqr5s rtest_draft_201909z"TestValidatorFor.test_draft_201909 xKL  $V , ,  +   LM  $V , ,  +     rcddi}|tj|tjddi}|tj|tjdS)Nrx,https://json-schema.org/draft/2020-12/schema-https://json-schema.org/draft/2020-12/schema#)rgrr{rr5s rtest_draft_202012z"TestValidatorFor.test_draft_202012-rrcj|tjdtjdS)NTrgrr{rr+s r test_TruezTestValidatorFor.test_True:s6  $T * *  &     rcj|tjdtjdSrrr+s r test_FalsezTestValidatorFor.test_False@s6  $U + +  &     rctjddidd}ddi}|tj||dS)Nreri12c.|ddSrkrmros rrqz8TestValidatorFor.test_custom_validator..Jrrrrsrxrr)rgr{r,r*rs rtest_custom_validatorz&TestValidatorFor.test_custom_validatorFsi%/0++   -.  $V , ,      rctjddid}ddi}|tj||dS)Nr"r|13rOrxrrs rtest_custom_validator_draft6z-TestValidatorFor.test_custom_validator_draft6Rsc% 12   ./  $V , ,      rcj|tjitjdSr/rr+s r%test_validator_for_jsonschema_defaultz6TestValidatorFor.test_validator_for_jsonschema_default]s* j.r22J4NOOOOOrcZ|tjidddS)Nr)rgrr{r+s r!test_validator_for_custom_defaultz2TestValidatorFor.test_validator_for_custom_default`s, j.r4@@@$GGGGGrc(|t5}tjddidddn #1swxYwY||jt |t|jddS)Nrx unknownSchemarzThe metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.) assertWarnsDeprecationWarningrr{r&filename__file__r9warning)r,r-s r1test_warns_if_meta_schema_specified_was_not_foundzBTestValidatorFor.test_warns_if_meta_schema_specified_was_not_foundcs   0 1 1 JR  $Y,H I I I I J J J J J J J J J J J J J J J h///   OO &     s?AActjd5}tjdtjiidddn #1swxYwY||dS)NT)recordalways)rr)warningscatch_warnings simplefilterrr{rh)r,ws r0test_does_not_warn_if_meta_schema_is_unspecifiedzATestValidatorFor.test_does_not_warn_if_meta_schema_is_unspecifiedos  $D 1 1 1 TestValidatorFor.test_validator_for_custom_default_with_schemaus<$&>? j.vw??IIIIIrN)rSrrTr|rrrrrrrrrrrrrrrrrrvrvs                                     PPPHHH     JJJJJrrvcJeZdZdZdZdZdZdZdZdZ dZ d Z d Z d S) TestValidatecg}tj|d|j5t ji|dddn #1swxYwY|||gdS)Nr)r patchrappendrrr&)r,rr*results r assertUseszTestValidate.assertUses{s Z  y.&- H H , ,  F + + + , , , , , , , , , , , , , , , &*****sA  AAc|dditj|dditjdS)Nrxrzrr*ry)rrrr+s rtest_draft3_validator_is_chosenz,TestValidate.test_draft3_validator_is_chosenb HI 0    GH 0      rc|dditj|dditjdS)Nrxrrr)rrrr+s rtest_draft4_validator_is_chosenz,TestValidate.test_draft4_validator_is_chosenrrc|dditj|dditjdS)Nrxrrr)rrrr+s rtest_draft6_validator_is_chosenz,TestValidate.test_draft6_validator_is_chosenrrc|dditj|dditjdS)Nrxrrr)rrrr+s rtest_draft7_validator_is_chosenz,TestValidate.test_draft7_validator_is_chosenrrc|dditj|dditjdS)Nrxrrrrrrr+s r$test_draft202012_validator_is_chosenz1TestValidate.test_draft202012_validator_is_chosensj J!5     I!5      rcH|itjdS)Nrrr+s r)test_draft202012_validator_is_the_defaultz6TestValidate.test_draft202012_validator_is_the_defaults! rZ-LMMMMMrc|tj5}tjdddidddn #1swxYwY|t |jddS)Nrrrz1(?s)Failed validating '.*' in schema.*On instance)rrrrr assertRegexr9r+rHs rtest_validation_error_messagez*TestValidate.test_validation_error_messages   z9 : : 8a  VX$6 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8     ?     AA Ac|tj5}tjdddidddn #1swxYwY|t |jddS)Nrrz3(?s)Failed validating '.*' in metaschema.*On schema)rrrrrrr9r+rHs rtest_schema_error_messagez&TestValidate.test_schema_error_messages   z5 6 6 2!  VRL 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2     A     rcddddddigi}|tj5}tjd|dddn #1swxYwY|dt |jdS) NrFrr[rrrrz!12 is less than the minimum of 20)rrrrrrvr9r+)r,rrjs rtest_it_uses_best_matchz$TestValidate.test_it_uses_best_matchs !b11!    z9 : : ,a  F + + + , , , , , , , , , , , , , , , 93q{;K;KLLLLLsA  AAN) rSrrTrrrrrrrrrrrrrrrzs+++                    NNN       M M M M MrrcxeZdZdZdZddiZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdS)TestRefResolverrlz foo://storedstoredrci|_|j|ji|_t j|j|j|j|_dSr/)referrer stored_uri stored_schemarrrbase_urirr+s rr-zTestRefResolver.setUps? ot'9: ". M4=$*   rctjjd}tj|jd5}|j|5} dddn #1swxYwYdddn #1swxYwY||tjj| |j dS)Nreresolve_remote) rrr1r rrrrr&rhcalled)r,rpatchedresolveds r6test_it_does_not_retrieve_schema_urls_from_the_networkzFTestRefResolver.test_it_does_not_retrieve_schema_urls_from_the_networks$(4T: Z  t}.> ? ? 7((--                                :#=#IJJJ (((((s5A=A& A=&A* *A=-A* .A==BBcd}dti|jd<|j|5}|||jddddddS#1swxYwYdS)Nz#/properties/foorrq)rrrrr&)r,rrs rtest_it_resolves_local_refsz+TestRefResolver.test_it_resolves_local_refss ',fhh&7 l# ] $ $S ) ) KX   Xt}\'B5'I J J J K K K K K K K K K K K K K K K K K Ks(A**A.1A.c~dddid}tj|d}|d5}|||ddddn #1swxYwY|d 5}|||dddddS#1swxYwYdS) Nzhttp://bar/schema#rr)rer[c.|ddSrkrmrs rrqzETestRefResolver.test_it_resolves_local_refs_with_id..D"!5!5rrtz#/ar[zhttp://bar/schema#/a)rr from_schemarr&r,rrrs r#test_it_resolves_local_refs_with_idz3TestRefResolver.test_it_resolves_local_refs_with_idsK,E5>BB)55 556     & & 4(   Xvc{ 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4    6 7 7 48   Xvc{ 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4s#A((A,/A,B22B69B6c^|j|j5}|||jdddn #1swxYwYddi|jjd<|jd5}||dddddS#1swxYwYdS)Nrr cached_refzcached_ref#/foo)rrrrgrrr&)r,rs rtest_it_retrieves_stored_refsz-TestRefResolver.test_it_retrieves_stored_refss& ] $ $T_ 5 5 8 MM(D$6 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8.3BK L) ] $ $%6 7 7 +8   Xr * * * + + + + + + + + + + + + + + + + + +s#AA A >B""B&)B&chd}ddi}dtjvr6|tjjdtjdt d|itjd<|j|5}||dddddS#1swxYwYdS)Nhttp://bar#bazr+rrequests http://bar)sysmodulesr% __setitem__ReallyFakeRequestsrrr&)r,rrrs r,test_it_retrieves_unstored_refs_via_requestsz.fake_urlopen sO   S, / / /$*V,,33F;;<< < < < < > ] $ $S ) ) .X   Xu - - - . . . . . . . . . . . . . . . . . .s#=A  A$'A$,CCCcddi}tj|d}||jd||jd|d5}|||dddn #1swxYwY|d5}|||dddn #1swxYwY|d5}|||dddn #1swxYwY|d5}|||ddddS#1swxYwYdS)Nrerc.|ddSrkrmrs rrqzPTestRefResolver.test_it_can_construct_a_base_uri_from_a_schema..9rrrrl#zfoo#rrrr&rresolution_scoperrs r.test_it_can_construct_a_base_uri_from_a_schemaz>TestRefResolver.test_it_can_construct_a_base_uri_from_a_schema5sd)55 556   *E222 2E:::    # # /x   Xv . . . / / / / / / / / / / / / / / /    $ $ /   Xv . . . / / / / / / / / / / / / / / /    & & /(   Xv . . . / / / / / / / / / / / / / / /    ' ' /8   Xv . . . / / / / / / / / / / / / / / / / / /sH2BBB5CCC8DD"D;EE#&E#ci}tj|}||jd||jd|d5}|||dddn #1swxYwY|d5}|||ddddS#1swxYwYdS)Nrlrrrs r9test_it_can_construct_a_base_uri_from_a_schema_without_idzITestRefResolver.test_it_can_construct_a_base_uri_from_a_schema_without_idFsV)55f== *B/// 2B777    # # /x   Xv . . . / / / / / / / / / / / / / / /    $ $ /   Xv . . . / / / / / / / / / / / / / / / / / /s$-BBB0CCCcfd}ddidtjdid|i}|5}|ddddS#1swxYwYdS)Nc4|Sr/r)rrrr,s rhandlerz@TestRefResolver.test_custom_uri_scheme_handlers..handlerQs   S# & & &Mrrr foo://barrlhandlers)rrrr&)r,rrrrrs` @@rtest_custom_uri_scheme_handlersz/TestRefResolver.test_custom_uri_scheme_handlersPs       )"bE7;KLLL    $ $ /   Xv . . . / / / / / / / / / / / / / / / / / /sA##A'*A'c&tgfd}d}tjdidd|i}||5 dddn #1swxYwY||5 ddddS#1swxYwYdS)Ncz S#t$rdYdSwxYw)Nz#Response must not have been cached!rR IndexErrorrrresponser,s rrz5TestRefResolver.test_cache_remote_on..handler^sR A||~~% A A A ?@@@@@@ A ::rrlTr cache_remoterrrrrr,rrrr s` @rtest_cache_remote_onz$TestRefResolver.test_cache_remote_on[sHHH: A A A A A A ) 0@      $ $                      $ $                     s$ AAA7BB  B ctgfd}d}tjdidd|i}||5 ddddS#1swxYwYdS)Ncz S#t$rdYdSwxYw)NzHandler called twice!rrs rrz6TestRefResolver.test_cache_remote_off..handlerpsM 3||~~% 3 3 3 1222222 3r!rrlFrr"r$r%s` @rtest_cache_remote_offz%TestRefResolver.test_cache_remote_offmsHH: 3 3 3 3 3 3 ) %1A      $ $                     s AAActdfd}d}tjdid|i}|tj5}||5|ddddn #1swxYwYdddn #1swxYwY||j t jdS)NzOh no! What's this?cr/r)rrs rrzTTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error..handlersKrrrlrrzShouldn't get this far!) r*rrrrRefResolutionErrorrrr&r+)r,rrrerrrs @r3test_if_you_give_it_junk_you_get_a_resolution_errorzCTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error}s]011     )"bE7;KLLL   z< = = 5##C(( 5 5 3444 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5  (Ee(L(LMMMMMs6B&B< BB BB BB#&B#c>tjdi}||tj5}|dddn #1swxYwY|dt|jdS)NrlzFailed to pop the scope) rr pop_scoperrr,rvr9r+)r,rexcs r.test_helpful_error_message_on_failed_pop_scopez>TestRefResolver.test_helpful_error_message_on_failed_pop_scopes)"b11   z< = = !     ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! /S]1C1CDDDDDs A**A.1A.N)rSrrTrrrr-rrrrrrr rrrr&r)r.r2rrrrrsHJx(M   )))KKK 4 4 4+++ + + +''',...///"/// / / /$ N N NEEEEErrc*d}t||S)NcFd|jDd|jDfS)Nc,g|]}t|Srr9rrjs rrz.sorted_errors..key..s ( ( (SVV ( ( (rc,g|]}t|Srr6r7s rrz.sorted_errors..key..s / / /SVV / / /r)r_r@)rs rkeyzsorted_errors..keys3 ( (UZ ( ( ( / /U. / / /  r)r9)sorted)rr9s rrfrfs&   &c " " ""rc2eZdZejZdZdS)rc|j|}|tdt|zt t j|S)Nz Unknown URL: ) _responsesrnr*rX_ReallyFakeJSONResponserr)r,rr s rrnzReallyFakeRequests.getsM?&&s++ ;_tCyy899 9&tz(';';<<c4tj|jSr/)rloads _responser+s rrz_ReallyFakeJSONResponse.jsonsz$.)))rN)rSrrTrrrBrrrrr>r>s2 I*****rr>)3 __future__r collectionsrr contextlibrdecimalriorrWr r urllib.requestr rrrrrr jsonschemar r rrrjsonschema.tests._helpersrrr rrXrrrrErZrirlrnrprtrvrrrfrprr>rrrrKs""""""))))))))%%%%%%########''''''  *)))))111 PIPIPIPIPI(PIPIPIfzCzCzCzCzC(zCzCzCz L  L  L  L  L  L  L  L  ^8888868888o-o-o-o-o--vo-o-o-dJJJJJ&JJJ<HHHHH-/A8HHH@)))))-/A8))) ))))),h))) ))))),h))) )))))18))) )))))18))) LJLJLJLJLJxLJLJLJ^^M^M^M^M^M8^M^M^MBtEtEtEtEtEhtEtEtEn###========*****f*****r