OwlCyberSecurity - MANAGER
Edit File: test_validators.cpython-37.opt-1.pyc
B �����pSe��������������������@���s���d�dl�mZ�d�dlmZ�d�dlmZ�d�dlmZ�d�dlm Z �d�dl Z d�dlZd�dlZd�dl Z d�dlZd�dlmZ�d�dlZd�dlmZmZmZmZ�d�d lmZmZ�d�d lmZ�dd��ZG�d d��de�ZG�dd��de�ZG�dd��de �ZG�dd��de �ZG�dd��de �Z G�dd��de!�Z"G�dd��de"e!�Z#G�dd��de!�Z$G�dd��de$e#e �Z%G�dd ��d e$e#e �Z&G�d!d"��d"e#e �Z'G�d#d$��d$e#e �Z(G�d%d&��d&e�Z)G�d'd(��d(e�Z*G�d)d*��d*e�Z+d+d,��Z,ej-G�d-d.��d.e!��Z.ej-G�d/d0��d0e!��Z/dS�)1�����)�deque)�contextmanager)�Decimal)�BytesIO)�TestCaseN)�SynchronousTestCase)� FormatChecker�TypeChecker� exceptions� validators)�PY3�pathname2url)�bugc�������������c���s���|��|�st�d�V��d�S�)NzWhoops!)� startswithr ����ValidationError)� validatorr����instance�schema��r����Q/opt/alt/python37/lib/python3.7/site-packages/jsonschema/tests/test_validators.pyr������s���� r���c���������������@���sd���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��Zdd��Zdd��Z dS�)�TestCreateAndExtendc�������������C���sP���|���|�jtjttj���ddi|�_dti|�_t��|�_tj |�j|�j|�jd�|�_ d�S�)Nz$idzsome://meta/schemar���)�meta_schemar����type_checker)� addCleanup�assertEqualr����meta_schemas�dictr���r���r ���r����create� Validator)�selfr���r���r����setUp���s���� zTestCreateAndExtend.setUpc�������������C���s.���|���|�jj|�jj|�jjf|�j|�j|�jf��d�S�)N)r���r���� VALIDATORS�META_SCHEMA�TYPE_CHECKERr���r���r���)r���r���r���r���� test_attrs*���s����zTestCreateAndExtend.test_attrsc�������������C���s ���ddi}|���|��|�j|��d�S�)Nr����foo)r���r���r���)r���r���r���r���r���� test_init7���s����zTestCreateAndExtend.test_initc�������������C���s����ddi}|���|�j}t|d��}|��|g���tjdd|ddtdg�d�}t|d��}|��t|�d��|��|d����|�����d�S�) Nr���ZhelZhellozWhoops!Zgoodbye)r���r���r����validator_value�schema_path����r���) r����iter_errors�listr���r ���r���r����lenZ _contents)r���r���r*����errorsZexpected_errorr���r���r����test_iter_errors;���s����z$TestCreateAndExtend.test_iter_errorsc�������������C���s4���t�jddidd�}|��t�jjd��|��|jd��d�S�)Nz$id� somethingz my version)r����versionZMyVersionValidator)r���r���r���r����popr����__name__)r���r���r���r���r����.test_if_a_version_is_provided_it_is_registeredO���s ����zBTestCreateAndExtend.test_if_a_version_is_provided_it_is_registeredc�������������C���s,���t�tj�}tjddid��|��tj|��d�S�)N�id)r���)r���r���r���r���r���)r����originalr���r���r����6test_if_a_version_is_not_provided_it_is_not_registeredW���s���� zJTestCreateAndExtend.test_if_a_version_is_not_provided_it_is_not_registeredc�������������C���sB���d}d|i}t�j|ddd��d��|��t�jj|��|��|t�j��d�S�)Nzmeta schema idr4���z my versionc�������������S���s���|���dd�S�)Nr4�����)�get)�sr���r���r����<lambda>c��������zMTestCreateAndExtend.test_validates_registers_meta_schema_id.<locals>.<lambda>)r���r0����id_of)r���r���r���r���r1����assertIn)r����meta_schema_key�my_meta_schemar���r���r����'test_validates_registers_meta_schema_id\���s����z;TestCreateAndExtend.test_validates_registers_meta_schema_idc�������������C���s<���d}d|i}t�j|dd��|��t�jj|��|��|t�j��d�S�)Nzmeta schema $idz$idz my version)r���r0���)r���r���r���r���r1���r=���)r���r>���r?���r���r���r����.test_validates_registers_meta_schema_draft6_idi���s����zBTestCreateAndExtend.test_validates_registers_meta_schema_draft6_idc����������������sD���t�ji�dd���|��t��fdd�dg�fdddd d i�fdgD�����d�S�)Nr���)r���r���c�������������3���s$���|�]\}}��i��j�||d��V��qdS�))r����typeN)�is_type)�.0rB���r���)r���r���r���� <genexpr>y���s���z@TestCreateAndExtend.test_create_default_types.<locals>.<genexpr>�array)�booleanT)�integer����)�nullN)�numberg������(@�object)�stringr%���)r���r���� assertTrue�all)r���r���)r���r����test_create_default_typesu���s���� z-TestCreateAndExtend.test_create_default_typesc�������������C���s`���t�|�jj�}t��}tj|�jd|id�}|��|j|j|j|�jjft�||d�|�jj|�jj|f��d�S�)N�new)r���)rQ���) r���r���r!���rL���r����extendr���r"���r#���)r���r5���rQ����Extendedr���r���r����test_extend����s���� zTestCreateAndExtend.test_extendc����������������sf�����fdd�}d}d|d�}t�j|��j���j|d�}���|�|j�|��t��|�}���|�|j�|��dS�)zK Extending a validator preserves its notion of schema IDs. c����������������s���|���d��j�|���S�)N�__test__)r8���r����ID_OF)r���)r���r���r���r<�������s����z3TestCreateAndExtend.test_extend_idof.<locals>.id_ofzthe://correct/id/zthe://wrong/id/)z$idrU���)r���r���r���r<���N)r���r���r���r���rV���r"���rR���)r���r<���Z correct_idr���ZOriginalZDerivedr���)r���r����test_extend_idof����s���� z$TestCreateAndExtend.test_extend_idofN)r2���� __module__�__qualname__r ���r$���r&���r.���r3���r6���r@���rA���rP���rT���rW���r���r���r���r���r������s��� r���c���������������@���st���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��ZdS�)�TestLegacyTypeCheckingc���������� ���C���s:���t�ji�dd�}|��t|j�ddddddd h��|�����d�S�) Nr���)r���r���rF���rG���rH���rJ���rK���rL���rM���)r���r���r����set� DEFAULT_TYPES� flushWarnings)r���r���r���r���r���rP�������s���� z0TestLegacyTypeChecking.test_create_default_typesc�������������C���s����t�ji�dd�}t|j�}t��}t�j|d|id�}|��|j|j|j|j|j |i��j |�� ��d�d�ft||d�|j|j||j |j |�� ��d�d�f��d�S�)Nr���)r���r���rQ���)r���r����message)rQ���)r���r���r���r!���rL���rR���r���r"���r#���r\���r]���)r���r���r5���rQ���rS���r���r���r���rT�������s*���� z"TestLegacyTypeChecking.test_extendc�������������C���sP���ddi}|���t�|��d���tj|dttfid�}|��|�d���|�����d�S�)NrB���rM���rI���)�types)�assertFalser����Draft7Validator�is_valid�str�intrN���r]���)r���r���r���r���r���r����0test_types_redefines_the_validators_type_checker����s����zGTestLegacyTypeChecking.test_types_redefines_the_validators_type_checkerc���������� ���C���s.���|�j�tdtj|�j�j�jtji�i�dtid��d�S�)NzPThe default_types argument is deprecated. Use the type_checker argument instead.r%���)�categoryr^����filename�fr���r���� default_types) �assertWarns�DeprecationWarning�sys�modulesrX����__file__r���r���rL���)r���r���r���r����"test_providing_default_types_warns����s����z9TestLegacyTypeChecking.test_providing_default_types_warnsc���������� ���C���sv���t�ji�i�t��d�}|��t�j��}|j�W�dQ�R�X�|��dt|j���|��t�j���|i��j�W�dQ�R�X�|�� |�� ����dS�)a��� We raise an error when you ask a validator with non-default type checker for its DEFAULT_TYPES. The type checker argument is new, so no one but this library itself should be trying to use it, and doing so while then asking for DEFAULT_TYPES makes no sense (not to mention is deprecated), since type checkers are not strictly about Python type. )r���r���r���Nz=DEFAULT_TYPES cannot be used on Validators using TypeCheckers)r���r���r ����assertRaisesZ_DontDoThatr\���r=���rc���� exceptionr`���r]���)r���r����er���r���r����?test_cannot_ask_for_default_types_with_non_default_type_checker����s���� zVTestLegacyTypeChecking.test_cannot_ask_for_default_types_with_non_default_type_checkerc�������������C���s:���t�ji�i�t��d�}|��|������|i���|��|������d�S�)N)r���r���r���)r���r���r ���r`���r]���)r���r���r���r���r����2test_providing_explicit_type_checker_does_not_warn��s���� zITestLegacyTypeChecking.test_providing_explicit_type_checker_does_not_warnc�������������C���s6���t�ji�i�d�}|��|������|i���|��|������d�S�)N)r���r���)r���r���r`���r]���)r���r���r���r���r����$test_providing_neither_does_not_warn#��s����z;TestLegacyTypeChecking.test_providing_neither_does_not_warnc���������� ���C���sR���|���t��}tji�i�dtit��d��W�d�Q�R�X�|��dt|j���|�� |�� ����d�S�)Nr%���)r���r���ri���r���z:Do not specify default_types when providing a type checker)rp���� TypeErrorr���r���rL���r ���r=���rc���rq���r`���r]���)r���rr���r���r���r����5test_providing_default_types_with_type_checker_errors*��s����zLTestLegacyTypeChecking.test_providing_default_types_with_type_checker_errorsc���������� ���C���sZ���t�ji�i�dtid�}|��t��}t�j|i�t��d��W�d�Q�R�X�|��dt|j ���|�� ���d�S�)NrF���)r���r���ri���)r���r���z�Cannot extend a validator created with default_types with a type_checker. Update the validator to use a type_checker when created.)r���r���r+���rp���rv���rR���r ���r=���rc���rq���r]���)r���r���rr���r���r���r����<test_extending_a_legacy_validator_with_a_type_checker_errors9��s����zSTestLegacyTypeChecking.test_extending_a_legacy_validator_with_a_type_checker_errorsc�������������C���s8���t�ji�i�d�}|��|������t��|��|��|������d�S�)N)r���ri���)r���r���rN���r]���rR���r`���)r���r���r���r���r����1test_extending_a_legacy_validator_does_not_rewarnP��s���� zHTestLegacyTypeChecking.test_extending_a_legacy_validator_does_not_rewarnc�������������C���s@���t�ji�i�d�}|��|������|��tdtj|�jj�j t |d��d�S�)N)r���r���zcThe DEFAULT_TYPES attribute is deprecated. See the type checker attached to this validator instead.r\���)r���r���r`���r]���rj���rk���rl���rm���rX���rn����getattr)r���r���r���r���r����"test_accessing_default_types_warnsW��s����z9TestLegacyTypeChecking.test_accessing_default_types_warnsc�������������C���sD���t�ji�i�d�}|��|������|��tdtj|�jj�j t |i��d��d�S�)N)r���r���zcThe DEFAULT_TYPES attribute is deprecated. See the type checker attached to this validator instead.r\���)r���r���r`���r]���rj���rk���rl���rm���rX���rn���rz���)r���r���r���r���r����2test_accessing_default_types_on_the_instance_warnsi��s����zITestLegacyTypeChecking.test_accessing_default_types_on_the_instance_warnsc�������������C���sF���t�ji�i�d�}|��|������|�jtdtj|�jj�j |i�dt id��d�S�)N)r���r���zaThe types argument is deprecated. Provide a type_checker to jsonschema.validators.extend instead.�bar)rf���r^���rg���rh���r���r_���)r���r���r`���r]���rj���rk���rl���rm���rX���rn���rL���)r���r���r���r���r����"test_providing_types_to_init_warns{��s����z9TestLegacyTypeChecking.test_providing_types_to_init_warnsN)r2���rX���rY���rP���rT���re���ro���rs���rt���ru���rw���rx���ry���r{���r|���r~���r���r���r���r���rZ�������s���rZ���c���������������@���s$���e�Zd�Zdd��Zdd��Zdd��ZdS�)�TestIterErrorsc�������������C���s���t��i��|�_d�S�)N)r����Draft3Validatorr���)r���r���r���r���r ������s����zTestIterErrors.setUpc�������������C���sr���ddg}ddddgddd ggd d�}dd ��|�j��||�D��}d|d�f�dd|d�f�g}|��t|�t|���d�S�)Nr)�������rF����a�b�c�drr���rh�������)�disallow�enum�minItemsc�������������s���s���|�]}|j�V��qd�S�)N)r^���)rD���rr���r���r���r���rE������s����z2TestIterErrors.test_iter_errors.<locals>.<genexpr>z%r is disallowed for [1, 2]r����z[1, 2] is too shortz[1, 2] is not one of %rr����)r���r*���r����sorted)r���r���r���ZgotZexpectedr���r���r���r.������s����zTestIterErrors.test_iter_errorsc�������������C���s\���ddgddd�}dddid did dddd gd�d�i}t�|�j�||��}|��t|�d��d�S�)Nr����r)��������spam)r%���r}����baz�quux� propertiesrB���rM���r����� ���������������)�maximumr����)r%���r}���r����)r+���r���r*���r���r,���)r���r���r���r-���r���r���r����0test_iter_errors_multiple_failures_one_validator���s����z?TestIterErrors.test_iter_errors_multiple_failures_one_validatorN)r2���rX���rY���r ���r.���r����r���r���r���r���r������s���r���c���������������@���s����e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zdd��Zdd ��Zd!d"��Zd#d$��Zd%d&��Zd'd(��Zd)S�)*�TestValidationErrorMessagesc���������� ���O���sB���|��dtj��|��tj��}tj||f|�|��W�d�Q�R�X�|jjS�)N�cls) � setdefaultr���r����rp���r ���r����validaterq���r^���)r���r���r����args�kwargsrr���r���r���r����message_for���s����z'TestValidationErrorMessages.message_forc�������������C���s&���|�j�dddid�}|��|dd���d�S�)Nr)���rB���rM���)r���r���z1 is not of type %r)r����r���)r���r^���r���r���r����test_single_type_failure���s����z4TestValidationErrorMessages.test_single_type_failurec�������������C���s(���|�j�dddgid�}|��|dd���d�S�)Nr)���rB���rM���)r���r���z1 is not of type %r)r����r���)r���r^���r���r���r����test_single_type_list_failure���s����z9TestValidationErrorMessages.test_single_type_list_failurec�������������C���s.���d}|�j�ddt|�id�}|��|d|���d�S�)N)rM���rL���r)���rB���)r���r���z1 is not of type %r, %r)r����r+���r���)r���r_���r^���r���r���r����test_multiple_type_failure���s����z6TestValidationErrorMessages.test_multiple_type_failurec�������������C���s2���dddigi}|�j�dd|gid�}|��|d��d�S�)NrB����minimumr����r)���)r���r���z1 is less than the minimum of 3)r����r���)r���rB���r^���r���r���r����&test_object_without_title_type_failure���s����zBTestValidationErrorMessages.test_object_without_title_type_failurec�������������C���s.���dddd�gi}|�j�d|d�}|��|d��d�S�)NrB���ZFoor����)�namer����r)���)r���r���z1 is less than the minimum of 3)r����r���)r���r���r^���r���r���r����#test_object_with_named_type_failure���s����z?TestValidationErrorMessages.test_object_with_named_type_failurec�������������C���s"���|�j�dddid�}|��|d��d�S�)Nr)���r����r����)r���r���z1 is less than the minimum of 2)r����r���)r���r^���r���r���r����test_minimum���s����z(TestValidationErrorMessages.test_minimumc�������������C���s"���|�j�dddid�}|��|d��d�S�)Nr)���r����r���)r���r���z"1 is greater than the maximum of 0)r����r���)r���r^���r���r���r����test_maximum���s����z(TestValidationErrorMessages.test_maximumc�������������C���sB���d\}}d||ii}|�j�ddi|tjd�}|��|d||f���d�S�)N)r}���r%����dependenciesr}���r����)r���r���r����z%r is a dependency of %r)r����r���r����r���)r����depend�onr���r^���r���r���r���� test_dependencies_single_element���s���� z<TestValidationErrorMessages.test_dependencies_single_elementc�������������C���sD���d\}}d||gii}|�j�ddi|tjd�}|��|d||f���d�S�)N)r}���r%���r����r}���r����)r���r���r����z%r is a dependency of %r)r����r���r����r���)r���r����r����r���r^���r���r���r����test_dependencies_list_draft3���s���� z9TestValidationErrorMessages.test_dependencies_list_draft3c�������������C���sD���d\}}d||gii}|�j�ddi|tjd�}|��|d||f���d�S�)N)r}���r%���r����r}���r����)r���r���r����z%r is a dependency of %r)r����r���ra���r���)r���r����r����r���r^���r���r���r����test_dependencies_list_draft7���s���� z9TestValidationErrorMessages.test_dependencies_list_draft7c�������������C���s&���|�j�dgg�dd�d�}|��d|��d�S�)Nr����F)�items�additionalItems)r���r���z(2 was unexpected))r����r=���)r���r^���r���r���r����#test_additionalItems_single_failure���s����z?TestValidationErrorMessages.test_additionalItems_single_failurec�������������C���s*���|�j�dddgg�dd�d�}|��d|��d�S�)Nr)���r����r����F)r����r����)r���r���z(1, 2, 3 were unexpected))r����r=���)r���r^���r���r���r����&test_additionalItems_multiple_failures���s����zBTestValidationErrorMessages.test_additionalItems_multiple_failuresc�������������C���s4���d}ddi}|�j�|di|d�}|��d|f�|��d�S�)Nr%����additionalPropertiesFr����)r���r���z(%r was unexpected))r����r=���)r���Z additionalr���r^���r���r���r����(test_additionalProperties_single_failure��s����zDTestValidationErrorMessages.test_additionalProperties_single_failurec�������������C���sP���ddi}|�j�t�ddg�|d�}|��td�|��|��td�|��|��d|��d�S�)Nr����Fr%���r}���)r���r���zwere unexpected))r����r����fromkeysr=����repr)r���r���r^���r���r���r����+test_additionalProperties_multiple_failures ��s����zGTestValidationErrorMessages.test_additionalProperties_multiple_failuresc�������������C���s.���ddi}|�j�ddi|tjd�}|��d|��d�S�)N�constrI���r%���r}���)r���r���r����z12 was expected)r����r����Draft6Validatorr=���)r���r���r^���r���r���r���� test_const��s���� z&TestValidationErrorMessages.test_constc�������������C���s4���dddii}|�j�di�g�g|tjd�}|��d|��d�S�)N�containsr����rI���r����)r���r���r����z4None of [2, {}, []] are valid under the given schema)r����r���r����r=���)r���r���r^���r���r���r���� test_contains��s���� z)TestValidationErrorMessages.test_containsc�������������C���sd���t�dd�}|�d�dd����ddi}|�jd||d�}|��td�|��|��td�|��|��d |��d�S�) Nr���)Zformats�thingc�������������S���s���dS�)NFr���)�valuer���r���r���r:���+��r;���zQTestValidationErrorMessages.test_invalid_format_default_message.<locals>.<lambda>�formatZbla)r���r����format_checkerzis not a)r����checksr����r=���r����)r����checkerr���r^���r���r���r����#test_invalid_format_default_message)��s���� z?TestValidationErrorMessages.test_invalid_format_default_messagec���������� ���C���s����ddddiddid�d�}|�j�ddi|tjd �}|��|d �td�td�td����|�j�dd d�|tjd �}|��|d�td�td�td�td����d�S�)NrL���FrB���rM���)z^abc$z^def$)rB���r�����patternProperties�zebra�{���)r���r���r����z,{} does not match any of the regexes: {}, {}z^abc$z^def$i���)r�����fishz.{}, {} do not match any of the regexes: {}, {}r����)r����r����Draft4Validatorr���r����r����)r���r���r^���r���r���r����1test_additionalProperties_false_patternProperties8��s(���� zMTestValidationErrorMessages.test_additionalProperties_false_patternPropertiesc�������������C���s"���|�j�ddtjd�}|��d|��d�S�)Nr/���F)r���r���r����z'False schema does not allow 'something')r����r���ra���r=���)r���r^���r���r���r����test_False_schemaV��s ���� z-TestValidationErrorMessages.test_False_schemaN)r2���rX���rY���r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r���r���r���r���r�������s(��� r����c���������������@���s|���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��ZdS�)�TestValidationErrorDetailsc�������������C���s���d}dddiddigi}t��|�}t|�|��}|��t|�d��|d�}|��|jd��|��|j|d���|��|j|��|��|j |��|�� |j��|��|jt g����|��|jt g����|��|jt g����|��|jt dg���|��|jt dg���|��|jt dg���|��t|j�d ��t|j�\}}|��|jd��|��|j|d�d�d���|��|j|��|��|j |d�d���|��|j|��|��|jt g����|��|jt g����|��|jt g����|��|jt ddg���|��|jt ddg���|��|jt dddg���|��|j��|��|jd��|��|j|d�d�d���|��|j|��|��|j |d�d���|��|j|��|��|jt g����|��|jt g����|��|jt g����|��|jt ddg���|��|jt ddg���|��|jt dddg���|��t|j�d��d�S�) N�����anyOfr��������rB���rM���r)���r���r����)r���r����r+���r*���r���r,���r���r'���r���r����assertIsNone�parent�pathr���� relative_path� absolute_pathr(����relative_schema_path�absolute_schema_path�context� sorted_errors�assertIsr`���)r���r���r���r���r-���rr����e1�e2r���r���r���� test_anyOfb��s\���� z%TestValidationErrorDetails.test_anyOfc���������� ���C���s���ddi}dddiddddgiid�gi}t��|�}t|�|��}|��t|�d��|d �}|��|jd��|��|j|d���|��|j|��|��|j |��|�� |j��|��|jt g����|��|jt g����|��|jt g����|��|jt dg���|��|jt dg���|��|jt dg���|��t|j�d��t|j�\}}|��|jd��|��|j|d�d �d���|��|j|��|��|j |d�d ���|��|j|��|��|jt g����|��|jt g����|��|jt g����|��|jt d dg���|��|jt d dg���|��|jt dd dg���|��|j��|��|jd��|��|jdg��|��|jd��|��|j ddgi��|��|j|��|��|jt dg���|��|jt dg���|��|jt dg���|��|jt dd ddg���|��|jt dd ddg���|��|jt ddd ddg���|��|j��d�S�)Nr%���r)���rB���rH���rL���r����r����)rB���r����r���r����)r���r����r+���r*���r���r,���r���r'���r���r���r����r����r����r���r����r����r(���r����r����r����r����r����r`���)r���r���r���r���r-���rr���r����r����r���r���r���� test_type���sd���� z$TestValidationErrorDetails.test_typec������� ������C���s���ddgddd�}dddid did dddd gd�d�i}t��|�}|�|�}t|�\}}}}|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|jtdg���|��|j d ��|��|j d��|��|j d��|��|j d��d�S�)Nr����r)���r����r����)r%���r}���r����r����r����rB���rM���r����r����r����r����r����)r����r����)r%���r}���r����r}���r����r%���r����r����) r���r����r*���r����r���r����r���r����r����r���) r���r���r���r���r-���r����r�����e3�e4r���r���r����test_single_nesting���s0���� z.TestValidationErrorDetails.test_single_nestingc���������� ���C���s���ddddgid�dg}dddgddd gid ddid did�d�d�d�d�}t��|�}|�|�}t|�\}}}}} } |��|jtg����|��|jtdg���|��|jtddg���|��|jtdddg���|��| jtdddg���|��| jtddg���|��|jtdg���|��|jtddg���|��t|j�ddddg��|��t|j�ddddddg��|��t| j�dddddd g��|��t| j�ddddg��|��|j d��|��|j d��|��|j d��|��|j d��|��| j d ��|��| j d��d�S�)Nr)���r����r����)r%���r}���r����rM���rL���r����r����rF����requiredTr����)r}���r����)rB���r����)rB���r����r���r}���r%���rB���r����r����) r���r����r*���r����r���r����r���r(���r+���r���)r���r���r���r���r-���r����r����r����r����Ze5Ze6r���r���r����test_multiple_nesting��sD���� z0TestValidationErrorDetails.test_multiple_nestingc�������������C���sD��dddddgddiddd d iid�d�d �giiddgdd d iid�}dddddddiid�id�i}t��|�}|�|�\}|��|jtdg���|��|jtdddg���|j\}|��|jtdddg���|��|jtdddddddddg ���|j\}|��|jtdddddg���|��|jtdddddddddddddddg���d�S�)NZnoder����rL���r�����childrenrB���rM���z^.*$z$refz#/definitions/node)rB���r����)r����r����)rB���r����r�����root)ZdefinitionsrB���r����r����r����Zabr����r���r����)r���r����r*���r���r����r���r����r����)r���r���r���r���rr���r����r����r���r���r����test_recursiveF��sp���� z)TestValidationErrorDetails.test_recursivec�������������C���s����ddd�}dddd�i}t��|�}|�|�}t|�\}}|��|jtdg���|��|jtdg���|��|jd ��|��|jd ��d�S�)Nr}���r����)r}���r%���r����rH���r����)rB���r����r%���rB���r����)r���r����r*���r����r���r����r���r���)r���r���r���r���r-���r����r����r���r���r����test_additionalProperties���s���� z4TestValidationErrorDetails.test_additionalPropertiesc�������������C���s����ddd�}dddiddid�i}t��|�}|�|�}t|�\}}|��|jtd g���|��|jtd g���|��|jd��|��|jd��d�S�)Nr)���r����)r}���r%���r����rB���rM���r����r����r}���r%���)r���r����r*���r����r���r����r���r���)r���r���r���r���r-���r����r����r���r���r����test_patternProperties���s���� z1TestValidationErrorDetails.test_patternPropertiesc�������������C���s����ddg}g�ddd�d�}t��|�}|�|�}t|�\}}|��|jtdg���|��|jtdg���|��|jd��|��|jd ��d�S�) Nr%���r)���rH���r����)rB���r����)r����r����r���rB���r����)r���r����r*���r����r���r����r���r���)r���r���r���r���r-���r����r����r���r���r����test_additionalItems���s���� z/TestValidationErrorDetails.test_additionalItemsc�������������C���s����dddg}i�gddd�d�}t��|�}|�|�}t|�\}}|��|jtdg���|��|jtdg���|��|jd ��|��|jd ��d�S�)Nr%���r}���r)���rH���r����)rB���r����)r����r����r����rB���r����)r���r����r*���r����r���r����r���r���)r���r���r���r���r-���r����r����r���r���r����test_additionalItems_with_items���s���� z:TestValidationErrorDetails.test_additionalItems_with_itemsc�������������C���s����ddi}ddddiii}t��|�}|�|�\}|��|jd��|��|jdddidf���|��|jtg����|��|jtddg���d�S�)Nr%���rI���Z propertyNames�notr����z%r is not allowed for %r) r���ra���r*���r���r���r^���r����r���r(���)r���r���r���r����errorr���r���r����test_propertyNames���s���� z-TestValidationErrorDetails.test_propertyNamesc�������������C���sr���ddiddid�}t��|�}|�d�\}|��|jd��|��|jd��|��|jtg����|��|jtdddg���d�S�)Nr����rI���� ���)�if�thenz13 was expectedr����r����) r���ra���r*���r���r���r^���r����r���r(���)r���r���r���r����r���r���r����test_if_then���s���� z'TestValidationErrorDetails.test_if_thenc�������������C���sr���ddiddid�}t��|�}|�d�\}|��|jd��|��|jd��|��|jtg����|��|jtdddg���d�S�) Nr����rI���r����)r�����elser����z13 was expectedr����r����) r���ra���r*���r���r���r^���r����r���r(���)r���r���r���r����r���r���r����test_if_else��s���� z'TestValidationErrorDetails.test_if_elsec���������� ���C���sN���t��d�}|�d�\}|��|j|j|j|j|j|j fdd�d�ddt g��f��d�S�)NFrI���zFalse schema does not allow 12)r���ra���r*���r���r^���r���r'���r���r���r(���r���)r���r���r����r���r���r����test_boolean_schema_False��s���� z4TestValidationErrorDetails.test_boolean_schema_Falsec�������������C���s����ddddii�}}t�jd|it�jdi�||id�d�}|�d d i�\}|��|j|j|j|j|j |j |jfdddd td g�dditddg�f��d�S�)NZsomeRefr����rB���rH���z$refr7���)�store)�resolverr%���ZnotAnIntegerz''notAnInteger' is not of type 'integer') r���ra����RefResolverr*���r���r^���r���r'���r���r����r���r(���r���)r����refr���r���r����r���r���r����test_ref-��s(����z#TestValidationErrorDetails.test_refN)r2���rX���rY���r����r����r����r����r����r����r����r����r����r����r����r����r����r����r���r���r���r���r����_��s���BJ"6br����c���������������@���s,���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd S�) �MetaSchemaTestsMixinc���������� ���C���s2���|���tj���|�j�ddt��ii��W�d�Q�R�X�d�S�)Nr����Ztest)rp���r ����SchemaErrorr����check_schemarL���)r���r���r���r����test_invalid_propertiesM��s����z,MetaSchemaTestsMixin.test_invalid_propertiesc���������� ���C���s,���|���tj���|�j�ddi��W�d�Q�R�X�d�S�)Nr�����1)rp���r ���r����r���r����)r���r���r���r����test_minItems_invalid_stringQ��s����z1MetaSchemaTestsMixin.test_minItems_invalid_stringc�������������C���s���|�j��dg�i��dS�)z� Technically, all the spec says is they SHOULD have elements, not MUST. See https://github.com/Julian/jsonschema/issues/529. r����N)r���r����)r���r���r���r����test_enum_allows_empty_arraysV��s����z2MetaSchemaTestsMixin.test_enum_allows_empty_arraysc�������������C���s���|�j��dddgi��dS�)z� Technically, all the spec says is they SHOULD be unique, not MUST. See https://github.com/Julian/jsonschema/issues/529. r����rI���N)r���r����)r���r���r���r����!test_enum_allows_non_unique_items^��s����z6MetaSchemaTestsMixin.test_enum_allows_non_unique_itemsN)r2���rX���rY���r����r����r����r����r���r���r���r���r����K��s���r����c���������������@���s����e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��Ze� ed�dd���Zdd��Zdd��Zdd��Zdd��Zdd��Zd d!��Zd"d#��Zd$S�)%�ValidatorTestMixinc�������������C���s$���|�j�\}}|��|��|��|���d�S�)N)�validrN���r���rb���)r���r���r���r���r���r����test_valid_instances_are_validh��s���� z1ValidatorTestMixin.test_valid_instances_are_validc�������������C���s$���|�j�\}}|��|��|��|���d�S�)N)�invalidr`���r���rb���)r���r���r���r���r���r����$test_invalid_instances_are_not_validl��s���� z7ValidatorTestMixin.test_invalid_instances_are_not_validc�������������C���s ���|���t��t��i�jt��d��d�S�)N)r���)r���rL���r����)r���r���r���r����(test_non_existent_properties_are_ignoredp��s����z;ValidatorTestMixin.test_non_existent_properties_are_ignoredc�������������C���s���|���|��i��jtj��d�S�)N)ZassertIsInstancer���r����r���r����)r���r���r���r����.test_it_creates_a_ref_resolver_if_not_provideds��s���� zAValidatorTestMixin.test_it_creates_a_ref_resolver_if_not_providedc���������� ���C���sZ���dddi�}}t�jdi�||id�}|�jd|i|d�}|��tj���|�d���W�d�Q�R�X�d�S�)NZsomeCoolRefrB���rH���r7���)r����z$ref)r����)r���r����r���rp���r ���r���r����)r���r����r���r����r���r���r���r����#test_it_delegates_to_a_ref_resolvery��s ����z6ValidatorTestMixin.test_it_delegates_to_a_ref_resolverc���������� ������sR���G���fdd�dt��}|��}ddi}���tj�����j||d��d��W�dQ�R�X�dS�)zb Legacy RefResolvers support only the context manager form of resolution. c�������������������s���e�Zd�Ze��fdd��ZdS�)zXValidatorTestMixin.test_it_delegates_to_a_legacy_ref_resolver.<locals>.LegacyRefResolverc�������������3���s�������|d��ddiV��d�S�)Nzthe refrB���rH���)r���)�thisr����)r���r���r���� resolving���s����zbValidatorTestMixin.test_it_delegates_to_a_legacy_ref_resolver.<locals>.LegacyRefResolver.resolvingN)r2���rX���rY���r���r��r���)r���r���r����LegacyRefResolver���s���r��z$refzthe ref)r����N)rL���rp���r ���r���r���r����)r���r��r����r���r���)r���r����*test_it_delegates_to_a_legacy_ref_resolver���s ����z=ValidatorTestMixin.test_it_delegates_to_a_legacy_ref_resolverc�������������C���s���|���|��i���dd���d�S�)Nr%���rM���)rN���r���rC���)r���r���r���r����#test_is_type_is_true_for_valid_type���s����z6ValidatorTestMixin.test_is_type_is_true_for_valid_typec�������������C���s���|���|��i���dd���d�S�)Nr%���rF���)r`���r���rC���)r���r���r���r����&test_is_type_is_false_for_invalid_type���s����z9ValidatorTestMixin.test_is_type_is_false_for_invalid_typec�������������C���s4���|���|��i���dd���|���|��i���dd���d�S�)NTrH���rK���)r`���r���rC���)r���r���r���r����,test_is_type_evades_bool_inheriting_from_int���s����z?ValidatorTestMixin.test_is_type_evades_bool_inheriting_from_intz-In Python 3 json.load always produces unicodec�������������C���s���|���ddi��d��d�S�)NrB���rM���s���foo)r���r����)r���r���r���r����$test_string_a_bytestring_is_a_string���s����z7ValidatorTestMixin.test_string_a_bytestring_is_a_stringc�������������C���s���|���ddi��d��dS�)zF See https://github.com/Julian/jsonschema/issues/611. �patternr%���N)r���r����)r���r���r���r����#test_patterns_can_be_native_strings���s����z6ValidatorTestMixin.test_patterns_can_be_native_stringsc�������������C���s~���dddii}t�j|�j|�jj�ddd���d�}||�}|�ddtd�td ��g��d i�g�dd�g}|��dd ��|�|�D��|��d�S�)Nr����rB���rK���c�������������S���s���t�|tttf�ot�|t��S�)N)� isinstancerd����floatr����bool)r����r����r���r���r���r:������s���zGValidatorTestMixin.test_it_can_validate_with_decimals.<locals>.<lambda>)r���r)���g�������?r����r%���Tc�������������S���s���g�|�] }|j��qS�r���)r���)rD���r����r���r���r���� <listcomp>���s����zIValidatorTestMixin.test_it_can_validate_with_decimals.<locals>.<listcomp>) r���rR���r���r#����redefiner����r���r���r*���)r���r���r���r���r���r���r���r����"test_it_can_validate_with_decimals���s����z5ValidatorTestMixin.test_it_can_validate_with_decimalsc�������������C���s"���|�j�ddit��d�}|�d��d�S�)Nr����Zcarrot)r����Zbugs)r���r���r����)r���r���r���r���r����7test_it_returns_true_for_formats_it_does_not_know_about���s����zJValidatorTestMixin.test_it_returns_true_for_formats_it_does_not_know_aboutc�������������C���s���|���i��}|��|j��d�S�)N)r���r����r����)r���r���r���r���r����,test_it_does_not_validate_formats_by_default���s���� z?ValidatorTestMixin.test_it_does_not_validate_formats_by_defaultc���������� ������s|���t���}td���|jdtd����fdd��}�jddi|d�}|�d����tj��}|�d ��W�d�Q�R�X���|j j ����d�S�) NzBad!r%���)Zraisesc����������������s.���|�dkrdS�|�dkr���n���d�|����d�S�)N�goodT�badz What is {}? [Baby Don't Hurt Me])�failr����)r����)r��r���r���r����check���s ����zTValidatorTestMixin.test_it_validates_formats_if_a_checker_is_provided.<locals>.checkr����)r����r��r��)r���� ValueErrorr����r���r����rp���r ���r���r����rq����cause)r���r����r��r����cmr���)r��r���r����2test_it_validates_formats_if_a_checker_is_provided���s���� zEValidatorTestMixin.test_it_validates_formats_if_a_checker_is_providedc�������������C���sB���t���}d|gi}tj|�j|�jj�|dd���d�}||��d��d�S�)NrB���c�������������S���s ���t�|t�S�)N)r��rd���)r����r����r���r���r���r:������r;���z@ValidatorTestMixin.test_non_string_custom_type.<locals>.<lambda>)r���r����)rL���r���rR���r���r#���r��r����)r���Znon_string_typer����Crazyr���r���r����test_non_string_custom_type���s���� z.ValidatorTestMixin.test_non_string_custom_typec���������� ���C���s`���t�j|�j|�jj�ddd���d�}|��tj��}|ddi��d��W�dQ�R�X�|�� d t |j���dS�) z� A tuple instance properly formats validation errors for uniqueItems. See https://github.com/Julian/jsonschema/pull/224 rF���c�������������S���s ���t�|t�S�)N)r���tuple)r����r����r���r���r���r:������r;���zNValidatorTestMixin.test_it_properly_formats_tuples_in_errors.<locals>.<lambda>)r���ZuniqueItemsT)r)���r)���Nz(1, 1) has non-unique elements)r���rR���r���r#���r��rp���r ���r���r����r=���rc���rq���)r���ZTupleValidatorrr���r���r���r����)test_it_properly_formats_tuples_in_errors���s����z<ValidatorTestMixin.test_it_properly_formats_tuples_in_errorsN)r2���rX���rY���r����r��r��r��r��r��r ��r ��r���unittestZskipIfr���r��r��r��r��r��r��r ��r"��r���r���r���r���r����g��s"���r����c���������������@���sL���e�Zd�ZdZdd��Zdd��Ze�ed��dd���Z e�ed��d d ���Z dS�)�AntiDraft6LeakMixinzN Make sure functionality from draft 6 doesn't leak backwards in time. c���������� ���C���s:���|���tj��}|�j�d��W�d�Q�R�X�|��dt|j���d�S�)NTzTrue is not of type)rp���r ���r����r���r����r=���rc���rq���)r���rr���r���r���r����test_True_is_not_a_schema��s����z-AntiDraft6LeakMixin.test_True_is_not_a_schemac���������� ���C���s:���|���tj��}|�j�d��W�d�Q�R�X�|��dt|j���d�S�)NFzFalse is not of type)rp���r ���r����r���r����r=���rc���rq���)r���rr���r���r���r����test_False_is_not_a_schema��s����z.AntiDraft6LeakMixin.test_False_is_not_a_schemai��c���������� ���C���sJ���t��di��}|��t��}|�jd|d��d��W�d�Q�R�X�|��|jtj ��d�S�)Nr7���T)r����rI���) r���r����rp���� Exceptionr���r�����assertNotIsInstancerq���r ���r���)r���r����rr���r���r���r����5test_True_is_not_a_schema_even_if_you_forget_to_check��s����zIAntiDraft6LeakMixin.test_True_is_not_a_schema_even_if_you_forget_to_checkc���������� ���C���sJ���t��di��}|��t��}|�jd|d��d��W�d�Q�R�X�|��|jtj ��d�S�)Nr7���F)r����rI���) r���r����rp���r'��r���r����r(��rq���r ���r���)r���r����rr���r���r���r����6test_False_is_not_a_schema_even_if_you_forget_to_check��s����zJAntiDraft6LeakMixin.test_False_is_not_a_schema_even_if_you_forget_to_checkN)r2���rX���rY����__doc__r%��r&��r#���skipr���r)��r*��r���r���r���r���r$�����s ���r$��c���������������@���sF���e�Zd�ZejZi�i�fZddidfZdd��Zdd��Z dd ��Z d d��ZdS�) �TestDraft3ValidatorrB���rH���r%���c�������������C���s���|���ddi�}|�t����d�S�)NrB����any)r���r����rL���)r���r���r���r���r����#test_any_type_is_valid_for_type_any��s����z7TestDraft3Validator.test_any_type_is_valid_for_type_anyc���������� ���C���s\���t�j|�j|�jj�ddd���d�}|ddi�}|�d��|��tj���|�d��W�dQ�R�X�dS�) z( Sigh, because why not. r.��c�������������S���s ���t�|t�S�)N)r��rd���)r����r����r���r���r���r:���*��r;���zBTestDraft3Validator.test_any_type_is_redefinable.<locals>.<lambda>)r���rB���rI���r%���N) r���rR���r���r#���r��r����rp���r ���r���)r���r��r���r���r���r����test_any_type_is_redefinable#��s���� z0TestDraft3Validator.test_any_type_is_redefinablec�������������C���s"���|���|��i���t��ddi���d�S�)NrB���r.��)rN���r���rb���rL���)r���r���r���r����!test_is_type_is_true_for_any_type2��s����z5TestDraft3Validator.test_is_type_is_true_for_any_typec�������������C���s8���|���|��i���dd���|���|��i���dddi���d�S�)NTrG���rB���r.��)rN���r���rC���rb���)r���r���r���r����6test_is_type_does_not_evade_bool_if_it_is_being_tested5��s����zJTestDraft3Validator.test_is_type_does_not_evade_bool_if_it_is_being_testedN)r2���rX���rY���r���r����r���r����r���r/��r0��r1��r2��r���r���r���r���r-����s���r-��c���������������@���s&���e�Zd�ZejZi�i�fZddidfZdS�)�TestDraft4ValidatorrB���rH���r%���N)r2���rX���rY���r���r����r���r����r���r���r���r���r���r3��:��s���r3��c���������������@���s&���e�Zd�ZejZi�i�fZddidfZdS�)�TestDraft6ValidatorrB���rH���r%���N)r2���rX���rY���r���r����r���r����r���r���r���r���r���r4��@��s���r4��c���������������@���s&���e�Zd�ZejZi�i�fZddidfZdS�)�TestDraft7ValidatorrB���rH���r%���N)r2���rX���rY���r���ra���r���r����r���r���r���r���r���r5��F��s���r5��c���������������@���sl���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��Zdd��Zdd��Z dd��ZdS�)�TestValidatorForc�������������C���s<���ddi}|���t�|�tj��ddi}|���t�|�tj��d�S�)Nz$schemaz&http://json-schema.org/draft-03/schemaz'http://json-schema.org/draft-03/schema#)r����r���� validator_forr����)r���r���r���r���r����test_draft_3M��s����zTestValidatorFor.test_draft_3c�������������C���s<���ddi}|���t�|�tj��ddi}|���t�|�tj��d�S�)Nz$schemaz&http://json-schema.org/draft-04/schemaz'http://json-schema.org/draft-04/schema#)r����r���r7��r����)r���r���r���r���r����test_draft_4Z��s����zTestValidatorFor.test_draft_4c�������������C���s<���ddi}|���t�|�tj��ddi}|���t�|�tj��d�S�)Nz$schemaz&http://json-schema.org/draft-06/schemaz'http://json-schema.org/draft-06/schema#)r����r���r7��r����)r���r���r���r���r����test_draft_6g��s����zTestValidatorFor.test_draft_6c�������������C���s<���ddi}|���t�|�tj��ddi}|���t�|�tj��d�S�)Nz$schemaz&http://json-schema.org/draft-07/schemaz'http://json-schema.org/draft-07/schema#)r����r���r7��ra���)r���r���r���r���r����test_draft_7t��s����zTestValidatorFor.test_draft_7c�������������C���s���|���t�d�tj��d�S�)NT)r����r���r7���_LATEST_VERSION)r���r���r���r���� test_True���s����zTestValidatorFor.test_Truec�������������C���s���|���t�d�tj��d�S�)NF)r����r���r7��r<��)r���r���r���r���� test_False���s����zTestValidatorFor.test_Falsec�������������C���s6���t�jddiddd��d�}ddi}|��t��|�|��d�S�)Nr4���zmeta schema idZ12c�������������S���s���|���dd�S�)Nr4���r7���)r8���)r9���r���r���r���r:������r;���z8TestValidatorFor.test_custom_validator.<locals>.<lambda>)r���r0���r<���z$schema)r���r���r����r7��)r���r���r���r���r���r����test_custom_validator���s����z&TestValidatorFor.test_custom_validatorc�������������C���s0���t�jddidd�}ddi}|��t��|�|��d�S�)Nz$idzmeta schema $idZ13)r���r0���z$schema)r���r���r����r7��)r���r���r���r���r���r����test_custom_validator_draft6���s����z-TestValidatorFor.test_custom_validator_draft6c�������������C���s���|���t�i��tj��d�S�)N)r����r���r7��r<��)r���r���r���r����%test_validator_for_jsonschema_default���s����z6TestValidatorFor.test_validator_for_jsonschema_defaultc�������������C���s���|���tji�d�d�d���d�S�)N)�default)r����r���r7��)r���r���r���r����!test_validator_for_custom_default���s����z2TestValidatorFor.test_validator_for_custom_defaultc�������������C���s,���|�j�tdtj|�j�j�jtjddii�d��d�S�)Nz�The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.z$schemaZ unknownSchema)rf���r^���rg���rh���r���rB��)rj���rk���rl���rm���rX���rn���r���r7��)r���r���r���r����1test_warns_if_meta_schema_specified_was_not_found���s����zBTestValidatorFor.test_warns_if_meta_schema_specified_was_not_foundc�������������C���s"���t�ji�i�d�f�|��|������d�S�)N)r���rB��)r���r7��r`���r]���)r���r���r���r����0test_does_not_warn_if_meta_schema_is_unspecified���s����zATestValidatorFor.test_does_not_warn_if_meta_schema_is_unspecifiedN)r2���rX���rY���r8��r9��r:��r;��r=��r>��r?��r@��rA��rC��rD��rE��r���r���r���r���r6��L��s��� r6��c���������������@���sT���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��ZdS�)�TestValidatec�������������C���s2���g�}|���|d|j��t�i�|��|��||g��d�S�)Nr����)�patch�appendr���r����r���)r���r���r����resultr���r���r���� assertUses���s����zTestValidate.assertUsesc�������������C���s,���|�j�dditjd��|�j�dditjd��d�S�)Nz$schemaz'http://json-schema.org/draft-03/schema#)r���r���z&http://json-schema.org/draft-03/schema)rJ��r���r����)r���r���r���r����test_draft3_validator_is_chosen���s���� z,TestValidate.test_draft3_validator_is_chosenc�������������C���s,���|�j�dditjd��|�j�dditjd��d�S�)Nz$schemaz'http://json-schema.org/draft-04/schema#)r���r���z&http://json-schema.org/draft-04/schema)rJ��r���r����)r���r���r���r����test_draft4_validator_is_chosen���s���� z,TestValidate.test_draft4_validator_is_chosenc�������������C���s,���|�j�dditjd��|�j�dditjd��d�S�)Nz$schemaz'http://json-schema.org/draft-06/schema#)r���r���z&http://json-schema.org/draft-06/schema)rJ��r���r����)r���r���r���r����test_draft6_validator_is_chosen���s���� z,TestValidate.test_draft6_validator_is_chosenc�������������C���s,���|�j�dditjd��|�j�dditjd��d�S�)Nz$schemaz'http://json-schema.org/draft-07/schema#)r���r���z&http://json-schema.org/draft-07/schema)rJ��r���ra���)r���r���r���r����test_draft7_validator_is_chosen���s���� z,TestValidate.test_draft7_validator_is_chosenc�������������C���s���|�j�i�tjd��d�S�)N)r���r���)rJ��r���ra���)r���r���r���r����$test_draft7_validator_is_the_default���s����z1TestValidate.test_draft7_validator_is_the_defaultc���������� ���C���s>���|���tj��}t�dddi��W�d�Q�R�X�|��t|j�d��d�S�)NrI���rB���rM���z3(?s)Failed validating u?'.*' in schema.*On instance)rp���r ���r���r���r�����assertRegexpMatchesrc���rq���)r���rr���r���r���r����test_validation_error_message���s ����z*TestValidate.test_validation_error_messagec���������� ���C���s>���|���tj��}t�dddi��W�d�Q�R�X�|��t|j�d��d�S�)NrI���rB���z5(?s)Failed validating u?'.*' in metaschema.*On schema)rp���r ���r����r���r����rP��rc���rq���)r���rr���r���r���r����test_schema_error_message���s ����z&TestValidate.test_schema_error_messagec���������� ���C���sN���dddiddigi}|���tj��}t�d|��W�d�Q�R�X�|��dt|j���d�S�)NZoneOfrB���rM���rF���rI���z12 is not of type)rp���r ���r���r���r����r=���rc���rq���)r���r���rr���r���r���r����test_it_uses_best_match��s����z$TestValidate.test_it_uses_best_matchN)r2���rX���rY���rJ��rK��rL��rM��rN��rO��rQ��rR��rS��r���r���r���r���rF�����s���rF��c���������������@���s����e�Zd�ZdZdZddiZdd��Zdd��Zd d ��Zdd��Z d d��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zdd��Zdd��Zdd ��Zd!d"��Zd#S�)$�TestRefResolverr7���zfoo://storedZstoredr���c�������������C���s.���i�|�_�|�j|�ji|�_t�|�j|�j�|�j�|�_d�S�)N)�referrer� stored_uri� stored_schemar����r���r�����base_urir����)r���r���r���r���r �����s����zTestRefResolver.setUpc���������� ������sP���t�jjd�}�����jd��fdd�����j�|��}W�d�Q�R�X����|t�jj��d�S�)Nr4���Zresolve_remotec�����������������s �������d�S�)NzShould not have been called!)r��)r����r����)r���r���r���r:�����r;���zXTestRefResolver.test_it_does_not_retrieve_schema_urls_from_the_network.<locals>.<lambda>)r���r����r"���rG��r����r��r���)r���r�����resolvedr���)r���r����6test_it_does_not_retrieve_schema_urls_from_the_network��s���� zFTestRefResolver.test_it_does_not_retrieve_schema_urls_from_the_networkc���������� ���C���sF���d}dt���i|�jd<�|�j�|��}|��||�jd�d���W�d�Q�R�X�d�S�)Nz#/properties/foor%���r����)rL���rU��r����r��r���)r���r����rY��r���r���r����test_it_resolves_local_refs%��s����z+TestRefResolver.test_it_resolves_local_refsc���������� ���C���sr���dddid�}t�jj|dd��d�}|�d��}|��||d ���W�d�Q�R�X�|�d ��}|��||d ���W�d�Q�R�X�d�S�)Nzhttp://bar/schema#r%���r}���)r4���r����c�������������S���s���|���dd�S�)Nr4���r7���)r8���)r���r���r���r���r:���/��r;���zETestRefResolver.test_it_resolves_local_refs_with_id.<locals>.<lambda>)r<���z#/ar����zhttp://bar/schema#/a)r���r�����from_schemar��r���)r���r���r����rY��r���r���r����#test_it_resolves_local_refs_with_id+��s����z3TestRefResolver.test_it_resolves_local_refs_with_idc���������� ���C���s`���|�j��|�j��}|��||�j��W�d�Q�R�X�ddi|�j�jd<�|�j��d��}|��|d��W�d�Q�R�X�d�S�)Nr%���rI���Z cached_refzcached_ref#/foo)r����r��rV��r����rW��r����r���)r���rY��r���r���r����test_it_retrieves_stored_refs6��s ����z-TestRefResolver.test_it_retrieves_stored_refsc���������� ���C���sh���d}ddi}dt�jkr.|��t�jjdt�jd���td|i�t�jd<�|�j�|��}|��|d��W�d�Q�R�X�d�S�)Nzhttp://bar#bazr����rI����requestsz http://bar)rl���rm���r����__setitem__�ReallyFakeRequestsr����r��r���)r���r����r���rY��r���r���r����,test_it_retrieves_unstored_refs_via_requests>��s���� z<TestRefResolver.test_it_retrieves_unstored_refs_via_requestsc���������� ������s����d}ddi��dt�jkr.��t�jjdt�jd���d�t�jd<�t���fdd��}��ttdtj��|t_�j� |��}W�d�Q�R�X��� |d��d�S�)Nzhttp://bar#bazr����rI���r_��c�������������3���s&������|�d��tt�����d��V��d�S�)Nz http://bar�utf8)r���r����json�dumps�encode)�url)r���r���r���r����fake_urlopenU��s����zQTestRefResolver.test_it_retrieves_unstored_refs_via_urlopen.<locals>.fake_urlopen�urlopen)rl���rm���r���r`��r����setattrr���ri��r����r��r���)r���r����rh��rY��r���)r���r���r����+test_it_retrieves_unstored_refs_via_urlopenK��s���� z;TestRefResolver.test_it_retrieves_unstored_refs_via_urlopenc���������� ���C���sr���t�jddd��&}|��tj|j��t�ddi|��W�d�Q�R�X�d�t |j��}|�j �|��}|��|d��W�d�Q�R�X�d�S�)NFZwt)�delete�moder%���r}���z file://{}#foo) �tempfileZNamedTemporaryFiler����os�remover����rd���dumpr����r ���r����r��r���)r���Ztempfr����rY��r���r���r����(test_it_retrieves_local_refs_via_urlopena��s����z8TestRefResolver.test_it_retrieves_local_refs_via_urlopenc���������� ���C���s����ddi}t�jj|dd��d�}|��|jd��|��|jd��|�d��}|��||��W�d�Q�R�X�|�d��}|��||��W�d�Q�R�X�|�d��}|��||��W�d�Q�R�X�|�d��}|��||��W�d�Q�R�X�d�S�) Nr4���r%���c�������������S���s���|���dd�S�)Nr4���r7���)r8���)r���r���r���r���r:���n��r;���zPTestRefResolver.test_it_can_construct_a_base_uri_from_a_schema.<locals>.<lambda>)r<���r7����#zfoo#)r���r����r\��r���rX���resolution_scoper��)r���r���r����rY��r���r���r����.test_it_can_construct_a_base_uri_from_a_schemaj��s����z>TestRefResolver.test_it_can_construct_a_base_uri_from_a_schemac���������� ���C���st���i�}t�j�|�}|��|jd��|��|jd��|�d��}|��||��W�d�Q�R�X�|�d��}|��||��W�d�Q�R�X�d�S�)Nr7���rs��)r���r����r\��r���rX��rt��r��)r���r���r����rY��r���r���r����9test_it_can_construct_a_base_uri_from_a_schema_without_id{��s����zITestRefResolver.test_it_can_construct_a_base_uri_from_a_schema_without_idc���������� ������sV�������fdd�}ddi�d��t�jdi�d|id�}|�����}��|���W�d�Q�R�X�d�S�)Nc����������������s������|������S�)N)r���)rg��)r����r���r���r���r����handler���s����z@TestRefResolver.test_custom_uri_scheme_handlers.<locals>.handlerr%���r}���z foo://barr7���)�handlers)r���r����r��r���)r���rw��r����rY��r���)r����r���r���r����test_custom_uri_scheme_handlers���s����z/TestRefResolver.test_custom_uri_scheme_handlersc���������� ������s`���t���g�����fdd�}d}tjdi�dd|id�}|�|���W�d�Q�R�X�|�|���W�d�Q�R�X�d�S�)Nc����������������s,���y������S��tk r&�����d��Y�nX�d�S�)Nz#Response must not have been cached!)r1���� IndexErrorr��)rg��)�responser���r���r���rw�����s����z5TestRefResolver.test_cache_remote_on.<locals>.handlerz foo://barr7���Tr%���)�cache_remoterx��)rL���r���r����r��)r���rw��r����r����r���)r{��r���r����test_cache_remote_on���s���� z$TestRefResolver.test_cache_remote_onc���������� ������sJ���t���g�����fdd�}d}tjdi�dd|id�}|�|���W�d�Q�R�X�d�S�)Nc����������������s,���y������S��tk r&�����d��Y�nX�d�S�)NzHandler called twice!)r1���rz��r��)rg��)r{��r���r���r���rw�����s����z6TestRefResolver.test_cache_remote_off.<locals>.handlerz foo://barr7���Fr%���)r|��rx��)rL���r���r����r��)r���rw��r����r����r���)r{��r���r����test_cache_remote_off���s����z%TestRefResolver.test_cache_remote_offc���������� ������s|���t�d�����fdd�}d}tjdi�d|id�}|��tj��&}|�|���|��d��W�d�Q�R�X�W�d�Q�R�X�|��|j t������d�S�) NzOh no! What's this?c����������������s������d�S�)Nr���)rg��)r����r���r���rw�����s����zTTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error.<locals>.handlerz foo://barr7���r%���)rx��zShouldn't get this far!) r��r���r����rp���r ����RefResolutionErrorr��r��r���rq���)r���rw��r����r�����errr���)r����r����3test_if_you_give_it_junk_you_get_a_resolution_error���s����zCTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_errorc���������� ���C���sJ���t��di��}|����|��tj��}|����W�d�Q�R�X�|��dt|j���d�S�)Nr7���zFailed to pop the scope) r���r����Z pop_scoperp���r ���r��r=���rc���rq���)r���r�����excr���r���r����.test_helpful_error_message_on_failed_pop_scope���s ����z>TestRefResolver.test_helpful_error_message_on_failed_pop_scopeN)r2���rX���rY���rX��rV��rW��r ���rZ��r[��r]��r^��rb��rk��rr��ru��rv��ry��r}��r~��r���r���r���r���r���r���rT�� ��s$��� rT��c�������������C���s���dd��}t�|�|d�S�)Nc�������������S���s ���dd��|�j�D��dd��|�jD��fS�)Nc�������������S���s���g�|�]}t�|��qS�r���)rc���)rD���rr���r���r���r���r�����s����z.sorted_errors.<locals>.key.<locals>.<listcomp>c�������������S���s���g�|�]}t�|��qS�r���)rc���)rD���rr���r���r���r���r�����s����)r����r(���)r����r���r���r����key���s����zsorted_errors.<locals>.key)r���)r����)r-���r���r���r���r���r�������s����r����c���������������@���s���e�Zd�Ze���Zdd��ZdS�)ra��c�������������C���s2���|�j��|�}|d�kr$tdt|����tt�|��S�)Nz Unknown URL: )� _responsesr8���r��r�����_ReallyFakeJSONResponserd��re��)r���rg��r{��r���r���r���r8������s����zReallyFakeRequests.getN)r2���rX���rY����attr�ibr���r8���r���r���r���r���ra�����s���ra��c���������������@���s���e�Zd�Ze���Zdd��ZdS�)r���c�������������C���s���t��|�j�S�)N)rd���loads� _response)r���r���r���r���rd�����s����z_ReallyFakeJSONResponse.jsonN)r2���rX���rY���r���r���r���rd��r���r���r���r���r������s���r���)0�collectionsr���� contextlibr���Zdecimalr����ior���r#��r���rd��ro��rl���rn��Ztwisted.trial.unittestr���r���Z jsonschemar���r ���r ���r���Zjsonschema.compatr���r ���Zjsonschema.tests._helpersr���r���r���rZ���r���r����r����rL���r����r����r$��r-��r3��r4��r5��r6��rF��rT��r����r9���ra��r���r���r���r���r����<module>���sV�����]"�/���o� sN�;