404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.147.74.100: ~ $
3

+;X	6�@s�ddlZddlmZmZddlmZddlmZmZGdd�dej	�Z
Gdd�dej	�ZGd	d
�d
ej	�ZGdd�dej	�Z
dS)
�N)�Draft4Validator�
exceptions)�PY3)�mock�unittestc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
TestBestMatchcCs@t|�}tj|�}tjt|��}d}|j|||j||�d�|S)Nz:Didn't return a consistent best match!
Got: {0}

Then: {1})�msg)�listr�
best_match�reversed�assertEqual�format)�self�errors�bestZ
reversed_bestr�r�%/usr/lib/python3.6/test_exceptions.pyr
	s
zTestBestMatch.best_matchcCsHtddddddiid�ii�}|j|jddgii��}|j|jd�dS)	N�
properties�foo��bar�type�object)�
minPropertiesrr)rr
�iter_errorsr�	validator)rrrrrr�(test_shallower_errors_are_better_matchessz6TestBestMatch.test_shallower_errors_are_better_matchescCsJtdddiddigddiddigd��}|j|ji��}|j|jd�dS)zo
        A property you *must* match is probably better than one you have to
        match a part of.

        rr�stringZnumber)r�anyOf�oneOfrN)rr
rrr)rrrrrr�%test_oneOf_and_anyOf_are_weak_matches!sz3TestBestMatch.test_oneOf_and_anyOf_are_weak_matchesc	CsRtdddddiddddiiigiii�}|j|jdddii��}|j|jd�d	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.

        rrrrrr�array�N)rr
rr�validator_value)rrrrrr�8test_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|jd�d	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#)rrrrrr�8test_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|jd�d	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#)rrrrrr�8test_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|jd�dS)	Nrrrrrrr!r")rr
rrr#)rrrrrr�test_nested_context_for_oneOf|s
z+TestBestMatch.test_nested_context_for_oneOfcCs6tddi�}|ji�\}|jtj|ji��jd�dS)Nrr)rrrrr
r)rr�errorrrr�test_one_error�s
zTestBestMatch.test_one_errorcCs"ti�}|jtj|ji���dS)N)rZassertIsNonerr
r)rrrrr�test_no_errors�szTestBestMatch.test_no_errorsN)�__name__�
__module__�__qualname__r
rr r$r%r&r'r)r*rrrrrs
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestByRelevancecCsbtjddgd�}tjdddgd�}t||gtjd�}|j||�t||gtjd�}|j||�dS)NzOh no!Zbaz)�pathzOh yes!rr)�key)r�ValidationError�max�	relevance�assertIs)r�shallow�deep�matchrrr�#test_short_paths_are_better_matches�sz3TestByRelevance.test_short_paths_are_better_matchescCs~tjdgd�}tjddgd�}t||gtjd�}|jdd�|D�dggg�t||gtjd�}|jdd�|D�dggg�dS)	NzOh no!)r/zOh yes!r)r0cSsg|]}t|j��qSr)r	r/)�.0r(rrr�
<listcomp>�szNTestByRelevance.test_global_errors_are_even_better_matches.<locals>.<listcomp>cSsg|]}t|j��qSr)r	r/)r9r(rrrr:�s)rr1�sortedr3r)rr5r6rrrr�*test_global_errors_are_even_better_matches�s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_priority�s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_priority�sz:TestByRelevance.test_strong_validators_are_higher_priorityN)r+r,r-r8r<rBrErrrrr.�s	r.c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
TestErrorTreecCs.dd�td�D�}tj|�}|j|jd�dS)NcSsg|]}tj��qSr)r�	MagicMock)r9�_rrrr:�szQTestErrorTree.test_it_knows_how_many_total_errors_it_contains.<locals>.<listcomp>�)�ranger�	ErrorTreerZtotal_errors)rr�treerrr�/test_it_knows_how_many_total_errors_it_contains�s
z=TestErrorTree.test_it_knows_how_many_total_errors_it_containscCs,tjddgd�g}tj|�}|jd|�dS)Nz	a messager)r/)rr1rK�assertIn)rrrLrrr�1test_it_contains_an_item_if_the_item_had_an_error�s
z?TestErrorTree.test_it_contains_an_item_if_the_item_had_an_errorcCs,tjddgd�g}tj|�}|jd|�dS)Nz	a messager)r/r)rr1rK�assertNotIn)rrrLrrr�9test_it_does_not_contain_an_item_if_the_item_had_no_error�s
zGTestErrorTree.test_it_does_not_contain_an_item_if_the_item_had_no_errorcCs0tjddd�}tj|g�}|j|jd|i�dS)Nz	a messager)r)rr1rKrr)rr(rLrrr�1test_validators_that_failed_appear_in_errors_dict�sz?TestErrorTree.test_validators_that_failed_appear_in_errors_dictcCsPtjddgd�tjdddgd�g}tj|�}|jd|d�|jd|d�dS)Nz
a bar messager)r/za bar -> 0 messager�)rr1rKrNrP)rrrLrrr�1test_it_creates_a_child_tree_for_each_nested_path�s

z?TestErrorTree.test_it_creates_a_child_tree_for_each_nested_pathcCsXtjddddgd�tjddddgd�}}tj||g�}|j|ddj||d��dS)	N�1rrr)rr/�2�quux)rrW)rr1rKrr)r�e1�e2rLrrr�+test_children_have_their_errors_dicts_built�sz9TestErrorTree.test_children_have_their_errors_dicts_builtcCs@tjddddgdd�tjddd	d
gdd�}}tj||g�dS)NrUrrZbar2Zi1)rr/�instancerVrWZfoobarrZi2)rr1rK)rrXrYrrr�-test_regression_multiple_errors_with_instance�s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|dtj�dS)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(rLrrr�9test_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_rrrrrF�s	rFc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestErrorInitReprStrcKs,tddddddid�}|j|�tjf|�S)NZhellorr�)�messagerr#r[�schema)�dict�updaterr1)r�kwargsZdefaultsrrr�
make_error#s
zTestErrorInitReprStr.make_errorcKs^tr|jdd�}tj|�jd�}|jf|�}t|�jd�\}}}|j||j	�|j||�dS)Nzu'�'�
)
r�replace�textwrap�dedent�rstriprg�str�	partitionrrb)rZexpectedrfr(Zmessage_linerH�restrrr�assertShows.sz TestErrorInitReprStr.assertShowscCs|j�}|jt|j�d�dS)NrS)rgZ
assertGreater�len�args)rr(rrr�!test_it_calls_super_and_sets_args8sz6TestErrorInitReprStr.test_it_calls_super_and_sets_argscCs |jttjdd��dd�dS)NzHello!)rbz<ValidationError: %r>)r�reprrr1)rrrr�	test_repr<szTestErrorInitReprStr.test_reprcCshtjd�}|jt|�d�dddddid�}x6|D].}t|�}||=tjd|�}|jt|�d�q2WdS)Nrbrrra)rr#r[rc)rb)rr1rrnrd)rr(rf�attr�krrr�test_unset_errorBs

z%TestErrorInitReprStr.test_unset_errorcCs|jdggd�dS)Nz�
            Failed validating u'type' in schema:
                {u'type': u'string'}

            On instance:
                5
            )r/�schema_path)rq)rrrr�test_empty_pathsSsz%TestErrorInitReprStr.test_empty_pathscCs|jddgdgd�dS)Nz�
            Failed validating u'type' in schema:
                {u'type': u'string'}

            On instance[0]:
                5
            r�items)r/rz)rq)rrrr�test_one_item_paths`sz(TestErrorInitReprStr.test_one_item_pathscCs|jdddgdddgd�dS)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)rrrr�test_multiple_item_pathsmsz-TestErrorInitReprStr.test_multiple_item_pathsc
Cs4tjd�� }t|j��|j|jd�WdQRXdS)Nzpprint.pformatr)rZpatchrnrgrZ
call_count)rZpformatrrr�test_uses_pprintzsz%TestErrorInitReprStr.test_uses_pprintcCs6tj�}tjdd|ddd�}t|�|j|jj�dS)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~rr�rrrrr`"s



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

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 113 B 0644
__init__.cpython-36.pyc File 113 B 0644
compat.cpython-36.opt-1.pyc File 305 B 0644
compat.cpython-36.pyc File 305 B 0644
test_cli.cpython-36.opt-1.pyc File 4.31 KB 0644
test_cli.cpython-36.pyc File 4.31 KB 0644
test_exceptions.cpython-36.opt-1.pyc File 13.37 KB 0644
test_exceptions.cpython-36.pyc File 13.37 KB 0644
test_format.cpython-36.opt-1.pyc File 2.74 KB 0644
test_format.cpython-36.pyc File 2.74 KB 0644
test_jsonschema_test_suite.cpython-36.opt-1.pyc File 9.67 KB 0644
test_jsonschema_test_suite.cpython-36.pyc File 9.71 KB 0644
test_validators.cpython-36.opt-1.pyc File 31.29 KB 0644
test_validators.cpython-36.pyc File 31.29 KB 0644