HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/jsonschema/tests/__pycache__/test_exceptions.cpython-38.pyc
U

>��]�;�@s�ddlmZddlZddlmZmZddlmZGdd�de�ZGdd�de�Z	Gd	d
�d
e�Z
Gdd�de�ZGd
d�de�ZdS)�)�TestCaseN)�Draft4Validator�
exceptions)�PY3c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
TestBestMatchcCsHt|�}t�|�}t�t|��}d}|j|��|��|�||�d�|S)Nz:Didn't return a consistent best match!
Got: {0}

Then: {1})�msg)�listr�
best_match�reversed�assertEqualZ	_contents�format)�self�errors�bestZ
reversed_bestr�r�B/usr/lib/python3/dist-packages/jsonschema/tests/test_exceptions.pyr		s

�zTestBestMatch.best_matchcCsHtddddddiid�ii�}|�|�ddgii��}|�|jd�dS)	N�
properties�foo��bar�type�object)�
minPropertiesrr�rr	�iter_errorsr�	validator�r
rrrrr�(test_shallower_errors_are_better_matchess
����
z6TestBestMatch.test_shallower_errors_are_better_matchescCsJtdddiddigddiddigd��}|�|�i��}|�|jd�dS)zn
        A property you *must* match is probably better than one you have to
        match a part of.
        rr�stringZnumber)r�anyOf�oneOfrNrrrrr�%test_oneOf_and_anyOf_are_weak_matches"s��z3TestBestMatch.test_oneOf_and_anyOf_are_weak_matchesc	CsRtdddddiddddiiigiii�}|�|�dddii��}|�|jd�d	S)
aL
        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_valuerrrr�8test_if_the_most_relevant_error_is_anyOf_it_is_traversed2s
�����zFTestBestMatch.test_if_the_most_relevant_error_is_anyOf_it_is_traversedc	CsRtdddddiddddiiigiii�}|�|�dddii��}|�|jd�d	S)
aL
        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.
        rrr rrrr"r#Nr$rrrr�8test_if_the_most_relevant_error_is_oneOf_it_is_traversedKs
�����zFTestBestMatch.test_if_the_most_relevant_error_is_oneOf_it_is_traversedc	CsRtdddddiddddiiigiii�}|�|�dddii��}|�|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#Nr$rrrr�8test_if_the_most_relevant_error_is_allOf_it_is_traversedds�����zFTestBestMatch.test_if_the_most_relevant_error_is_allOf_it_is_traversedcCs^tdddddidddiddddiiigigiii�}|�|�dddii��}|�|jd�dS)	Nrrr rrrr"r#r$rrrr�test_nested_context_for_oneOfys*���������z+TestBestMatch.test_nested_context_for_oneOfcCs6tddi�}|�i�\}|�t�|�i��jd�dS)Nrr)rrrrr	r)r
r�errorrrr�test_one_error�s�zTestBestMatch.test_one_errorcCs"ti�}|�t�|�i���dS)N)rZassertIsNonerr	r)r
rrrr�test_no_errors�szTestBestMatch.test_no_errorsN)�__name__�
__module__�__qualname__r	rr!r&r'r(r)r+r,rrrrrsrc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestByRelevancecCsbtjddgd�}tjdddgd�}t||gtjd�}|�||�t||gtjd�}|�||�dS)N�Oh no!Zbaz��path�Oh 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�}|�dd�|D�dggg�t||gtjd�}|�dd�|D�dggg�dS)	Nr1r2r4rr5cSsg|]}t|j��qSr�rr3��.0r*rrr�
<listcomp>�szNTestByRelevance.test_global_errors_are_even_better_matches.<locals>.<listcomp>cSsg|]}t|j��qSrr?r@rrrrB�s)rr7�sortedr9r)r
r;r<rrrr�*test_global_errors_are_even_better_matches�s��z:TestByRelevance.test_global_errors_are_even_better_matchescCshtjdgdd�}tjdgdd�}tjdd�}t||g|d�}|�||�t||g|d�}|�||�dS)Nr1�a�r3rr4�b)�weakr5�rr7Zby_relevancer8r:)r
rH�normalr	r=rrr�'test_weak_validators_are_lower_priority�sz7TestByRelevance.test_weak_validators_are_lower_prioritycCs~tjdgdd�}tjdgdd�}tjdgdd�}tjddd�}t|||g|d	�}|�||�t|||g|d	�}|�||�dS)
Nr1rErFr4rGzOh fine!�c)rH�strongr5rI)r
rHrJrMr	r=rrr�*test_strong_validators_are_higher_priority�sz:TestByRelevance.test_strong_validators_are_higher_priorityN)r-r.r/r>rDrKrNrrrrr0�s	r0c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
TestErrorTreecCs.dd�td�D�}t�|�}|�|jd�dS)NcSsg|]}tjd|d��qS)Z	Something�r)rr7)rA�irrrrB�s�zQTestErrorTree.test_it_knows_how_many_total_errors_it_contains.<locals>.<listcomp>�)�ranger�	ErrorTreerZtotal_errors�r
r�treerrr�/test_it_knows_how_many_total_errors_it_contains�s
�
z=TestErrorTree.test_it_knows_how_many_total_errors_it_containscCs,tjddgd�g}t�|�}|�d|�dS)N�	a messagerr2)rr7rT�assertInrUrrr�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}t�|�}|�d|�dS)NrXrr2r)rr7rT�assertNotInrUrrr�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�}t�|g�}|�|jd|i�dS)NrXrrP�rr7rTrr�r
r*rVrrr�1test_validators_that_failed_appear_in_errors_dict�sz?TestErrorTree.test_validators_that_failed_appear_in_errors_dictcCsPtjddgd�tjdddgd�g}t�|�}|�d|d�|�d|d�dS)Nz
a bar messagerr2za bar -> 0 messager�)rr7rTrYr[rUrrr�1test_it_creates_a_child_tree_for_each_nested_path�s�
z?TestErrorTree.test_it_creates_a_child_tree_for_each_nested_pathcCsXtjddddgd�tjddddgd�}}t�||g�}|�|ddj||d��dS)	N�1rrr)rr3�2�quux)rrdr])r
�e1�e2rVrrr�+test_children_have_their_errors_dicts_built�s
�z9TestErrorTree.test_children_have_their_errors_dicts_builtcCs@tjddddgdd�tjddd	d
gdd�}}t�||g�dS)NrbrrZbar2Zi1)rr3�instancercrdZfoobarrZi2)rr7rT)r
rerfrrr�"test_multiple_errors_with_instance�s���z0TestErrorTree.test_multiple_errors_with_instancec	Cs>tjddgd�}t�|g�}|�t��|dW5QRXdS)NZ123r)rrhr)rr7rTZassertRaises�
IndexErrorr^rrr�>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�}t�|g�}|�|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.
        rXr)rrhr3N)rr7rTZassertIsInstancer^rrr�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/rWrZr\r_rargrirkrlrrrrrO�s		rOc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestErrorInitReprStrcKs,tddddddid�}|�|�tjf|�S)NZhellorr�)�messagerr%rh�schema)�dict�updaterr7)r
�kwargs�defaultsrrr�
make_error"s�
zTestErrorInitReprStr.make_errorcKs^tr|�dd�}t�|��d�}|jf|�}t|��d�\}}}|�||j	�|�||�dS)Nzu'�'�
)
r�replace�textwrap�dedent�rstripru�str�	partitionrro)r
Zexpectedrsr*Zmessage_line�_�restrrr�assertShows-sz TestErrorInitReprStr.assertShowscCs|��}|�t|j�d�dS)Nr`)ruZ
assertGreater�len�args)r
r*rrr�!test_it_calls_super_and_sets_args7sz6TestErrorInitReprStr.test_it_calls_super_and_sets_argscCs |�ttjdd��dd�dS)NzHello!)roz<ValidationError: %r>)r�reprrr7�r
rrr�	test_repr;s�zTestErrorInitReprStr.test_reprcCsdt�d�}|�t|�d�dddddid�}|D].}t|�}||=tjd|�}|�t|�d�q0dS)Nrorrrn)rr%rhrp)ro)rr7rr|rq)r
r*rs�attr�krrr�test_unset_errorAs
�z%TestErrorInitReprStr.test_unset_errorcCs|jdggd�dS)Nz�
            Failed validating u'type' in schema:
                {u'type': u'string'}

            On instance:
                5
            �r3Zschema_path�r�r�rrr�test_empty_pathsRs
�z%TestErrorInitReprStr.test_empty_pathscCs|jddgdgd�dS)Nz�
            Failed validating u'type' in schema:
                {u'type': u'string'}

            On instance[0]:
                5
            r�itemsr�r�r�rrr�test_one_item_paths_s
�z(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
            rrEr�r`r�r�r�rrr�test_multiple_item_pathsls
�z-TestErrorInitReprStr.test_multiple_item_pathscCs0|jdttd��tttd�td���dd�dS)Na@
            Failed validating u'maxLength' in schema:
                {0: 0,
                 1: 1,
                 2: 2,
                 3: 3,
                 4: 4,
                 5: 5,
                 6: 6,
                 7: 7,
                 8: 8,
                 9: 9,
                 10: 10,
                 11: 11,
                 12: 12,
                 13: 13,
                 14: 14,
                 15: 15,
                 16: 16,
                 17: 17,
                 18: 18,
                 19: 19}

            On instance:
                [0,
                 1,
                 2,
                 3,
                 4,
                 5,
                 6,
                 7,
                 8,
                 9,
                 10,
                 11,
                 12,
                 13,
                 14,
                 15,
                 16,
                 17,
                 18,
                 19,
                 20,
                 21,
                 22,
                 23,
                 24]
            ��Z	maxLength)rhrpr)r�rrSrq�zipr�rrr�test_uses_pprintys2
�z%TestErrorInitReprStr.test_uses_pprintcsFG�fdd�dt�}|�}tjdd|ddd�}��t|�t|��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.
        cs$eZdZ�fdd�Z�fdd�ZdS)zdTestErrorInitReprStr.test_str_works_with_instances_having_overriden_eq_operator.<locals>.DontEQMeBrocs��d�dS�NzDon't!�Zfail��this�otherr�rr�__eq__�szkTestErrorInitReprStr.test_str_works_with_instances_having_overriden_eq_operator.<locals>.DontEQMeBro.__eq__cs��d�dSr�r�r�r�rr�__ne__�szkTestErrorInitReprStr.test_str_works_with_instances_having_overriden_eq_operator.<locals>.DontEQMeBro.__ne__N)r-r.r/r�r�rr�rr�DontEQMeBro�sr�rXrZsomerp)rrhr%rpN)rrr7rYr�r|)r
r�rhr*rr�r�:test_str_works_with_instances_having_overriden_eq_operator�s�zOTestErrorInitReprStr.test_str_works_with_instances_having_overriden_eq_operatorN)
r-r.r/rur�r�r�r�r�r�r�r�r�rrrrrm!s



9rmc@seZdZdd�ZdS)�TestHashablecCs$tt�d�g�tt�d�g�dS)N�)�setrr7ZSchemaErrorr�rrr�
test_hashable�szTestHashable.test_hashableN)r-r.r/r�rrrrr��sr�)
ZunittestrryZ
jsonschemarrZjsonschema.compatrrr0rOrmr�rrrr�<module>s4N+