File "test_exceptions.cpython-36.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/usr/lib/python3.6/site-packages/jsonschema/tests/__pycache__/test_exceptions.cpython-36.pyc
File size: 13.37 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit

3

+;X	6@sddlZddlmZmZddlmZddlmZmZGdddej	Z
Gdddej	ZGd	d
d
ej	ZGdddej	Z
dS)
N)Draft4Validator
exceptions)PY3)mockunittestc@sTeZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZdS)
TestBestMatchcCs@t|}tj|}tjt|}d}|j|||j||d|S)Nz:Didn't return a consistent best match!
Got: {0}

Then: {1})msg)listr
best_matchreversedassertEqualformat)selferrorsbestZ
reversed_bestrr%/usr/lib/python3.6/test_exceptions.pyr
	s
zTestBestMatch.best_matchcCsHtddddddiidii}|j|jddgii}|j|jddS)	N
propertiesfoobartypeobject)
minPropertiesrr)rr
iter_errorsr	validator)rrrrrr(test_shallower_errors_are_better_matchessz6TestBestMatch.test_shallower_errors_are_better_matchescCsJtdddiddigddiddigd}|j|ji}|j|jddS)zo
        A property you *must* match is probably better than one you have to
        match a part of.

        rrstringZnumber)ranyOfoneOfrN)rr
rrr)rrrrrr%test_oneOf_and_anyOf_are_weak_matches!sz3TestBestMatch.test_oneOf_and_anyOf_are_weak_matchesc	CsRtdddddiddddiiigiii}|j|jdddii}|j|jdd	S)
aM
        If the most relevant error is an anyOf, then we traverse its context
        and select the otherwise *least* relevant error, since in this case
        that means the most specific, deep, error inside the instance.

        I.e. since only one of the schemas must match, we look for the most
        relevant one.

        rrrrrrarrayN)rr
rrvalidator_value)rrrrrr8test_if_the_most_relevant_error_is_anyOf_it_is_traversed2szFTestBestMatch.test_if_the_most_relevant_error_is_anyOf_it_is_traversedc	CsRtdddddiddddiiigiii}|j|jdddii}|j|jdd	S)
aM
        If the most relevant error is an oneOf, then we traverse its context
        and select the otherwise *least* relevant error, since in this case
        that means the most specific, deep, error inside the instance.

        I.e. since only one of the schemas must match, we look for the most
        relevant one.

        rrrrrrr!r"N)rr
rrr#)rrrrrr8test_if_the_most_relevant_error_is_oneOf_it_is_traversedLszFTestBestMatch.test_if_the_most_relevant_error_is_oneOf_it_is_traversedc	CsRtdddddiddddiiigiii}|j|jdddii}|j|jdd	S)
z
        Now, if the error is allOf, we traverse but select the *most* relevant
        error from the context, because all schemas here must match anyways.

        rrZallOfrrrr!r"N)rr
rrr#)rrrrrr8test_if_the_most_relevant_error_is_allOf_it_is_traversedfszFTestBestMatch.test_if_the_most_relevant_error_is_allOf_it_is_traversedcCs^tdddddidddiddddiiigigiii}|j|jdddii}|j|jddS)	Nrrrrrrr!r")rr
rrr#)rrrrrrtest_nested_context_for_oneOf|s
z+TestBestMatch.test_nested_context_for_oneOfcCs6tddi}|ji\}|jtj|jijddS)Nrr)rrrrr
r)rrerrorrrrtest_one_errors
zTestBestMatch.test_one_errorcCs"ti}|jtj|jidS)N)rZassertIsNonerr
r)rrrrrtest_no_errorsszTestBestMatch.test_no_errorsN)__name__
__module____qualname__r
rr r$r%r&r'r)r*rrrrrs
rc@s,eZdZddZddZddZddZd	S)
TestByRelevancecCsbtjddgd}tjdddgd}t||gtjd}|j||t||gtjd}|j||dS)NzOh no!Zbaz)pathzOh yes!rr)key)rValidationErrormax	relevanceassertIs)rshallowdeepmatchrrr#test_short_paths_are_better_matchessz3TestByRelevance.test_short_paths_are_better_matchescCs~tjdgd}tjddgd}t||gtjd}|jdd|Ddgggt||gtjd}|jdd|DdgggdS)	NzOh no!)r/zOh yes!r)r0cSsg|]}t|jqSr)r	r/).0r(rrr
<listcomp>szNTestByRelevance.test_global_errors_are_even_better_matches.<locals>.<listcomp>cSsg|]}t|jqSr)r	r/)r9r(rrrr:s)rr1sortedr3r)rr5r6rrrr*test_global_errors_are_even_better_matchessz:TestByRelevance.test_global_errors_are_even_better_matchescCshtjdgdd}tjdgdd}tjdd}t||g|d}|j||t||g|d}|j||dS)NzOh no!a)r/rzOh yes!b)weak)r0)rr1by_relevancer2r4)rr?normalr
r7rrr'test_weak_validators_are_lower_prioritysz7TestByRelevance.test_weak_validators_are_lower_prioritycCs~tjdgdd}tjdgdd}tjdgdd}tjddd}t|||g|d	}|j||t|||g|d	}|j||dS)
NzOh no!r=)r/rzOh yes!r>zOh fine!c)r?strong)r0)rr1r@r2r4)rr?rArDr
r7rrr*test_strong_validators_are_higher_prioritysz:TestByRelevance.test_strong_validators_are_higher_priorityN)r+r,r-r8r<rBrErrrrr.s	r.c@sTeZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZdS)
TestErrorTreecCs.ddtdD}tj|}|j|jddS)NcSsg|]}tjqSr)r	MagicMock)r9_rrrr:szQTestErrorTree.test_it_knows_how_many_total_errors_it_contains.<locals>.<listcomp>)ranger	ErrorTreerZtotal_errors)rrtreerrr/test_it_knows_how_many_total_errors_it_containss
z=TestErrorTree.test_it_knows_how_many_total_errors_it_containscCs,tjddgdg}tj|}|jd|dS)Nz	a messager)r/)rr1rKassertIn)rrrLrrr1test_it_contains_an_item_if_the_item_had_an_errors
z?TestErrorTree.test_it_contains_an_item_if_the_item_had_an_errorcCs,tjddgdg}tj|}|jd|dS)Nz	a messager)r/r)rr1rKassertNotIn)rrrLrrr9test_it_does_not_contain_an_item_if_the_item_had_no_errors
zGTestErrorTree.test_it_does_not_contain_an_item_if_the_item_had_no_errorcCs0tjddd}tj|g}|j|jd|idS)Nz	a messager)r)rr1rKrr)rr(rLrrr1test_validators_that_failed_appear_in_errors_dictsz?TestErrorTree.test_validators_that_failed_appear_in_errors_dictcCsPtjddgdtjdddgdg}tj|}|jd|d|jd|ddS)Nz
a bar messager)r/za bar -> 0 messager)rr1rKrNrP)rrrLrrr1test_it_creates_a_child_tree_for_each_nested_paths

z?TestErrorTree.test_it_creates_a_child_tree_for_each_nested_pathcCsXtjddddgdtjddddgd}}tj||g}|j|ddj||ddS)	N1rrr)rr/2quux)rrW)rr1rKrr)re1e2rLrrr+test_children_have_their_errors_dicts_builtsz9TestErrorTree.test_children_have_their_errors_dicts_builtcCs@tjddddgddtjddd	d
gdd}}tj||gdS)NrUrrZbar2Zi1)rr/instancerVrWZfoobarrZi2)rr1rK)rrXrYrrr-test_regression_multiple_errors_with_instancesz;TestErrorTree.test_regression_multiple_errors_with_instancec	Cs>tjddgd}tj|g}|jt|dWdQRXdS)NZ123r)rr[r)rr1rKZassertRaises
IndexError)rr(rLrrr>test_it_does_not_contain_subtrees_that_are_not_in_the_instanceszLTestErrorTree.test_it_does_not_contain_subtrees_that_are_not_in_the_instancecCs6tjddidgd}tj|g}|j|dtjdS)z
        If a validator is dumb (like :validator:`required` in draft 3) and
        refers to a path that isn't in the instance, the tree still properly
        returns a subtree for that path.

        z	a messager)rr[r/N)rr1rKZassertIsInstance)rr(rLrrr9test_if_its_in_the_tree_anyhow_it_does_not_raise_an_errorszGTestErrorTree.test_if_its_in_the_tree_anyhow_it_does_not_raise_an_errorN)r+r,r-rMrOrQrRrTrZr\r^r_rrrrrFs	rFc@s\eZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZdS)TestErrorInitReprStrcKs,tddddddid}|j|tjf|S)NZhellorr)messagerr#r[schema)dictupdaterr1)rkwargsZdefaultsrrr
make_error#s
zTestErrorInitReprStr.make_errorcKs^tr|jdd}tj|jd}|jf|}t|jd\}}}|j||j	|j||dS)Nzu''
)
rreplacetextwrapdedentrstriprgstr	partitionrrb)rZexpectedrfr(Zmessage_linerHrestrrrassertShows.sz TestErrorInitReprStr.assertShowscCs|j}|jt|jddS)NrS)rgZ
assertGreaterlenargs)rr(rrr!test_it_calls_super_and_sets_args8sz6TestErrorInitReprStr.test_it_calls_super_and_sets_argscCs |jttjdddddS)NzHello!)rbz<ValidationError: %r>)rreprrr1)rrrr	test_repr<szTestErrorInitReprStr.test_reprcCshtjd}|jt|ddddddid}x6|D].}t|}||=tjd|}|jt|dq2WdS)Nrbrrra)rr#r[rc)rb)rr1rrnrd)rr(rfattrkrrrtest_unset_errorBs

z%TestErrorInitReprStr.test_unset_errorcCs|jdggddS)Nz
            Failed validating u'type' in schema:
                {u'type': u'string'}

            On instance:
                5
            )r/schema_path)rq)rrrrtest_empty_pathsSsz%TestErrorInitReprStr.test_empty_pathscCs|jddgdgddS)Nz
            Failed validating u'type' in schema:
                {u'type': u'string'}

            On instance[0]:
                5
            ritems)r/rz)rq)rrrrtest_one_item_paths`sz(TestErrorInitReprStr.test_one_item_pathscCs|jdddgdddgddS)Nz
            Failed validating u'type' in schema[u'items'][0]:
                {u'type': u'string'}

            On instance[0][u'a']:
                5
            rr=r|rS)r/rz)rq)rrrrtest_multiple_item_pathsmsz-TestErrorInitReprStr.test_multiple_item_pathsc
Cs4tjd }t|j|j|jdWdQRXdS)Nzpprint.pformatr)rZpatchrnrgrZ
call_count)rZpformatrrrtest_uses_pprintzsz%TestErrorInitReprStr.test_uses_pprintcCs6tj}tjdd|ddd}t||j|jjdS)z
        Check for https://github.com/Julian/jsonschema/issues/164 which
        rendered exceptions unusable when a `ValidationError` involved
        instances with an `__eq__` method that returned truthy values.

        z	a messagerZsomerc)rr[r#rcN)rrGrr1rnZassertFalse__eq__Zcalled)rr[r(rrr:test_str_works_with_instances_having_overriden_eq_operatorszOTestErrorInitReprStr.test_str_works_with_instances_having_overriden_eq_operatorN)
r+r,r-rgrqrtrvryr{r}r~rrrrrrr`"s



r`)rkZ
jsonschemarrZjsonschema.compatrZjsonschema.tests.compatrrZTestCaserr.rFr`rrrr<module>s4L