Prv8 Shell
Server : Apache
System : Linux server.mata-lashes.com 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64
User : matalashes ( 1004)
PHP Version : 8.1.29
Disable Function : NONE
Directory :  /usr/local/lib/python3.6/site-packages/jsonschema/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/lib/python3.6/site-packages/jsonschema/tests/__pycache__/test_exceptions.cpython-36.pyc
3

F�KdT=�@sxddlmZddlZddlmZmZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de�Z	Gdd
�d
e�Z
dS)�)�TestCaseN)�Draft4Validator�
exceptionsc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
TestBestMatchcCsHt|�}tj|�}tjt|��}d}|j|j�|j�|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�F/tmp/pip-build-8nxjc3nm/jsonschema/jsonschema/tests/test_exceptions.pyrs
zTestBestMatch.best_matchcCsHtddddddiid�ii�}|j|jddgii��}|j|jd�dS)	N�
properties�foo��bar�type�object)�
minPropertiesrr)rr�iter_errorsr
�	validator)rrrrrr�(test_shallower_errors_are_better_matchessz6TestBestMatch.test_shallower_errors_are_better_matchescCsJtdddiddigddiddigd��}|j|ji��}|j|jd�dS)zn
        A property you *must* match is probably better than one you have to
        match a part of.
        rr�string�number)r�anyOf�oneOfrN)rrrr
r)rrrrrr�%test_oneOf_and_anyOf_are_weak_matches!sz3TestBestMatch.test_oneOf_and_anyOf_are_weak_matchesc	CsRtdddddiddddiiigiii�}|j|jdddii��}|j|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)rrrr
�validator_value)rrrrrr�8test_if_the_most_relevant_error_is_anyOf_it_is_traversed1s
zFTestBestMatch.test_if_the_most_relevant_error_is_anyOf_it_is_traversedc	CsRtdddddiddddiiigiii�}|j|jdddii��}|j|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.
        rrrrrrr r!N)rrrr
r")rrrrrr�8test_if_the_most_relevant_error_is_oneOf_it_is_traversedJs
zFTestBestMatch.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)rrrr
r")rrrrrr�8test_if_the_most_relevant_error_is_allOf_it_is_traversedcszFTestBestMatch.test_if_the_most_relevant_error_is_allOf_it_is_traversedcCs^tdddddidddiddddiiigigiii�}|j|jdddii��}|j|jd�dS)	Nrrrrrrr r!)rrrr
r")rrrrrr�test_nested_context_for_oneOfxs
z+TestBestMatch.test_nested_context_for_oneOfcCs6tddi�}|ji�\}|jtj|ji��jd�dS)Nrr)rrr
rrr)rr�errorrrr�test_one_error�s
zTestBestMatch.test_one_errorcCs"ti�}|jtj|ji���dS)N)rZassertIsNonerrr)rrrrr�test_no_errors�szTestBestMatch.test_no_errorsN)�__name__�
__module__�__qualname__rrrr#r$r%r&r(r)rrrrrsrc@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)r/cSsg|]}t|j��qSr)rr.)�.0r'rrr�
<listcomp>�szNTestByRelevance.test_global_errors_are_even_better_matches.<locals>.<listcomp>cSsg|]}t|j��qSr)rr.)r8r'rrrr9�s)rr0�sortedr2r
)rr4r5r
rrr�*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)r/)rr0�by_relevancer1r3)rr>�normalrr6rrr�'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)r/)rr0r?r1r3)rr>r@rCrr6rrr�*test_strong_validators_are_higher_priority�sz:TestByRelevance.test_strong_validators_are_higher_priorityN)r*r+r,r7r;rArDrrrrr-�s	r-c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�
TestErrorTreecCs.dd�td�D�}tj|�}|j|jd�dS)NcSsg|]}tjd|d��qS)Z	Something)r)rr0)r8�irrrr9�szQTestErrorTree.test_it_knows_how_many_total_errors_it_contains.<locals>.<listcomp>�)�ranger�	ErrorTreer
Z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}tj|�}|jd|�dS)Nz	a messager)r.)rr0rI�assertIn)rr
rJrrr�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)rr0rI�assertNotIn)rr
rJrrr�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)rr0rIr
r
)rr'rJrrr�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�)rr0rIrLrN)rr
rJrrr�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)rrU)rr0rIr
r
)r�e1�e2rJrrr�+test_children_have_their_errors_dicts_built�sz9TestErrorTree.test_children_have_their_errors_dicts_builtcCs@tjddddgdd�tjddd	d
gdd�}}tj||g�dS)NrSrr�bar2�i1)rr.�instancerTrU�foobarr�i2)rr0rI)rrVrWrrr�"test_multiple_errors_with_instance�sz0TestErrorTree.test_multiple_errors_with_instancec	Cs>tjddgd�}tj|g�}|jt��|dWdQRXdS)NZ123r)rr[r)rr0rIZassertRaises�
IndexError)rr'rJrrr�>test_it_does_not_contain_subtrees_that_are_not_in_the_instances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)rr0rIZassertIsInstance)rr'rJrrr�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_errorcCsPtjddddgdd�tjddd	d
gdd�}}tj||g�}|jt|�d�dS)
NrSrrrYrZ)rr.r[rTrUr\rr]z<ErrorTree (2 total errors)>)rr0rIr
�repr)rrVrWrJrrr�	test_reprszTestErrorTree.test_reprN)
r*r+r,rKrMrOrPrRrXr^r`rarcrrrrrE�s		
rEc@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�updaterr0)r�kwargs�defaultsrrr�
make_error1s
zTestErrorInitReprStr.make_errorcKsNtj|�jd�}|jf|�}t|�jd�\}}}|j||j�|j||�dS)N�
)�textwrap�dedent�rstriprl�str�	partitionr
rf)r�expectedrjr'Zmessage_line�_�restrrr�assertShows<s
z TestErrorInitReprStr.assertShowscCs|j�}|jt|j�d�dS)NrQ)rlZ
assertGreater�len�args)rr'rrr�!test_it_calls_super_and_sets_argsDsz6TestErrorInitReprStr.test_it_calls_super_and_sets_argscCs|jttjdd��d�dS)NzHello!)rfz<ValidationError: 'Hello!'>)r
rbrr0)rrrrrcHszTestErrorInitReprStr.test_reprcCshtjd�}|jt|�d�dddddid�}x6|D].}t|�}||=tjd|�}|jt|�d�q2WdS)Nrfrrre)rr"r[rg)rf)rr0r
rqrh)rr'rj�attr�krrr�test_unset_errorNs

z%TestErrorInitReprStr.test_unset_errorcCs|jdggd�dS)Nz�
            Failed validating 'type' in schema:
                {'type': 'string'}

            On instance:
                5
            )r.�schema_path)rv)rrrr�test_empty_paths_sz%TestErrorInitReprStr.test_empty_pathscCs|jddgdgd�dS)Nz�
            Failed validating 'type' in schema:
                {'type': 'string'}

            On instance[0]:
                5
            r�items)r.r})rv)rrrr�test_one_item_pathslsz(TestErrorInitReprStr.test_one_item_pathscCs|jdddgdddgd�dS)Nz�
            Failed validating 'type' in schema['items'][0]:
                {'type': 'string'}

            On instance[0]['a']:
                5
            rr<rrQ)r.r})rv)rrrr�test_multiple_item_pathsysz-TestErrorInitReprStr.test_multiple_item_pathscCs0|jdttd��tttd�td���dd�dS)Na?
            Failed validating '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)r[rgr)rvrrHrh�zip)rrrr�test_uses_pprint�s
2
z%TestErrorInitReprStr.test_uses_pprintcsFG�fdd�dt�}|�}tjdd|ddd�}�jt|�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�jd�dS)NzDon't!)�fail)�this�other)rrr�__eq__�szkTestErrorInitReprStr.test_str_works_with_instances_having_overriden_eq_operator.<locals>.DontEQMeBro.__eq__cs�jd�dS)NzDon't!)r�)r�r�)rrr�__ne__�szkTestErrorInitReprStr.test_str_works_with_instances_having_overriden_eq_operator.<locals>.DontEQMeBro.__ne__N)r*r+r,r�r�r)rrr�DontEQMeBro�sr�z	a messagerZsomerg)rr[r"rgN)rrr0rLrbrq)rr�r[r'r)rr�:test_str_works_with_instances_having_overriden_eq_operator�szOTestErrorInitReprStr.test_str_works_with_instances_having_overriden_eq_operatorN)
r*r+r,rlrvryrcr|r~r�r�r�r�rrrrrd0s


9rdc@seZdZdd�ZdS)�TestHashablecCs$ttjd�g�ttjd�g�dS)N�)�setrr0ZSchemaError)rrrr�
test_hashable�szTestHashable.test_hashableN)r*r+r,r�rrrrr��sr�)ZunittestrrnZ
jsonschemarrrr-rErdr�rrrr�<module>s4^)

haha - 2025