관리-도구
편집 파일: test_validators.cpython-39.opt-1.pyc
a ����ki�]������������������������@���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�)N�Whoops!)� startswithr ����ValidationError)� validatorr����instance�schema��r����D/usr/lib/python3.9/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�)N�$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���ZhelZhellor���Zgoodbye)r���r���r����validator_value�schema_path����r���) r!����iter_errors�listr���r ���r���r����lenZ _contents)r#���r���r0����errorsZexpected_errorr���r���r����test_iter_errors;���s����� z$TestCreateAndExtend.test_iter_errorsc�����������������C���s4���t�jddidd�}|��t�jjd��|��|jd��d�S�)Nr���� something� 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�)N�meta schema idr=���r6���c�����������������S���s���|���dd�S��Nr=�������get��sr���r���r����<lambda>c��������zMTestCreateAndExtend.test_validates_registers_meta_schema_id.<locals>.<lambda>�r���r8����id_of�r���r ���r���r���r9����assertIn�r#���Zmeta_schema_keyZmy_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�)N�meta schema $idr���r6���r7���rK���rM���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�fdfD�����d�S�)Nr����r���r���c�����������������3���s$���|�]\}}��i��j�||d��V��qdS�))r����typeN)�is_type)�.0rR���r����r!���r���r���� <genexpr>x���s����z@TestCreateAndExtend.test_create_default_types.<locals>.<genexpr>�array)�booleanT)�integer����)�nullN)�numberg������(@�object)�stringr*���)r���r ���� assertTrue�allr"���r���rU���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����rb���) r���r!���r&���r]���r����extendr���r'���r(���)r#���r>���rb����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__)rD���r!����ID_OF�r���r"���r���r���rJ�������s����z3TestCreateAndExtend.test_extend_idof.<locals>.id_ofzthe://correct/id/zthe://wrong/id/)r���rh���)r���r���r���rJ���N)r���r ���r���r���ri���r'���re���)r#���rJ���Z correct_idr���ZOriginalZDerivedr���r"���r����test_extend_idof����s������ z$TestCreateAndExtend.test_extend_idofN)r:���� __module__�__qualname__r$���r)���r,���r4���r<���r?���rN���rP���ra���rg���rk���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���s0���t�ji�dd�}|��t|j�h�d���|�����d�S�)Nr���rQ���>���rX���r[���rW���rY���r\���r]���r^���)r���r ���r����set� DEFAULT_TYPES� flushWarningsr;���r���r���r���ra�������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���rQ���rb���rc���r����messagerd���)r���r ���r���r&���r]���re���r���r'���r(���rp���rq���)r#���r!���r>���rb���rf���r���r���r���rg�������s2���� �� ��z"TestLegacyTypeChecking.test_extendc�����������������C���sP���ddi}|���t�|��d���tj|dttfid�}|��|�d���|�����d�S�)NrR���r^���rZ���)�types)�assertFalser����Draft7Validator�is_valid�str�intr_���rq���)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*���)�categoryrr����filename�fr���r���� default_types) �assertWarns�DeprecationWarning�sys�modulesrl����__file__r���r ���r]���r"���r���r���r����"test_providing_default_types_warns����s�����z9TestLegacyTypeChecking.test_providing_default_types_warnsc�����������������C���s����t�ji�i�t��d�}|��t�j��}|j�W�d����n1�s:0����Y��|��dt|j���|��t�j���|i��j�W�d����n1�s�0����Y��|�� |�� ����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���Nz=DEFAULT_TYPES cannot be used on Validators using TypeCheckers)r���r ���r ����assertRaisesZ_DontDoThatrp���rL���rw���� exceptionrt���rq����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�)Nr���)r���r ���r ���rt���rq���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�)NrQ���)r���r ���rt���rq���r;���r���r���r����$test_providing_neither_does_not_warn#��s����z;TestLegacyTypeChecking.test_providing_neither_does_not_warnc�����������������C���sf���|���t��(}tji�i�dtit��d��W�d�����n1�s80����Y��|��dt|j���|�� |�� ����d�S�)Nr*���)r���r���r}���r���z:Do not specify default_types when providing a type checker)r����� TypeErrorr���r ���r]���r ���rL���rw���r����rt���rq����r#���r����r���r���r����5test_providing_default_types_with_type_checker_errors*��s�����$�zLTestLegacyTypeChecking.test_providing_default_types_with_type_checker_errorsc�����������������C���sn���t�ji�i�dtid�}|��t��"}t�j|i�t��d��W�d�����n1�sF0����Y��|��dt|j ���|�� ���d�S�)NrW���)r���r���r}���)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 ���r1���r����r����re���r ���rL���rw���r����rq���r����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���r}���)r���r ���r_���rq���re���rt���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��NrQ���zcThe DEFAULT_TYPES attribute is deprecated. See the type checker attached to this validator instead.rp����r���r ���rt���rq���r~���r���r����r����rl���r�����getattrr;���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�r����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�)NrQ���zaThe types argument is deprecated. Provide a type_checker to jsonschema.validators.extend instead.�bar)rz���rr���r{���r|���r���rs���)r���r ���rt���rq���r~���r���r����r����rl���r����r]���r;���r���r���r����"test_providing_types_to_init_warns{��s�����z9TestLegacyTypeChecking.test_providing_types_to_init_warnsN)r:���rl���rm���ra���rg���ry���r����r����r����r����r����r����r����r����r����r����r���r���r���r���rn�������s���rn���c�������������������@���s$���e�Zd�Zdd��Zdd��Zdd��ZdS�)�TestIterErrorsc�����������������C���s���t��i��|�_d�S�r%���)r����Draft3Validatorr���r"���r���r���r���r$������s����zTestIterErrors.setUpc�����������������C���sn���ddg}dg�d�g�d�gdd�}dd ��|�j��||�D��}d |d�f�dd |d�f�g}|��t|�t|���d�S�)Nr/�������rW���)�a�b�c)�dr����r|�������)�disallow�enum�minItemsc�����������������s���s���|�]}|j�V��qd�S�r%���)rr����rT���r����r���r���r���rV������rH���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���r0���r����sorted)r#���r���r���ZgotZexpectedr���r���r���r4������s������zTestIterErrors.test_iter_errorsc�����������������C���sX���ddgddd�}dddid did g�d�d�d �i}t�|�j�||��}|��t|�d��d�S�)Nr����r/��������spam�r*���r�����baz�quux� propertiesrR���r^���r����� ����r������������������maximumr�����r*���r����r����r����)r1���r���r0���r���r2���)r#���r���r���r3���r���r���r����0test_iter_errors_multiple_failures_one_validator���s������z?TestIterErrors.test_iter_errors_multiple_failures_one_validatorN)r:���rl���rm���r$���r4���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���s\���|��dtj��|��tj��*}tj||g|�R�i�|���W�d�����n1�sJ0����Y��|jjS�)N�cls) � setdefaultr���r����r����r ���r����validater����rr���)r#���r���r����args�kwargsr����r���r���r����message_for���s����8z'TestValidationErrorMessages.message_forc�����������������C���s&���|�j�dddid�}|��|dd���d�S��Nr/���rR���r^����r���r���z1 is not of type %r�r����r����r#���rr���r���r���r����test_single_type_failure���s����z4TestValidationErrorMessages.test_single_type_failurec�����������������C���s(���|�j�dddgid�}|��|dd���d�S�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)r^���r]���r/���rR���r����z1 is not of type %r, %r)r����r1���r���)r#���rs���rr���r���r���r����test_multiple_type_failure���s����z6TestValidationErrorMessages.test_multiple_type_failurec�����������������C���s2���dddigi}|�j�dd|gid�}|��|d��d�S�)NrR����minimumr����r/���r�����1 is less than the minimum of 3r����)r#���rR���rr���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�)NrR���ZFoor����)�namer����r/���r����r����r�����r#���r���rr���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����z1 is less than the minimum of 2r����r����r���r���r����test_minimum���s����z(TestValidationErrorMessages.test_minimumc�����������������C���s"���|�j�dddid�}|��|d��d�S�)Nr/���r����r���r����z"1 is greater than the maximum of 0r����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*���Zdependenciesr����r�����r���r���r����z%r is a dependency of %r�r����r���r����r����r#���ZdependZonr���rr���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�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�r����)r����r���ru���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��itemsZadditionalItemsr����z(2 was unexpected)�r����rL���r����r���r���r����#test_additionalItems_single_failure���s �����z?TestValidationErrorMessages.test_additionalItems_single_failurec�����������������C���s(���|�j�g�d�g�dd�d�}|��d|��d�S�)N)r/���r����r����Fr����r����z(1, 2, 3 were unexpected)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����z(%r was unexpected)r����)r#���� additionalr���rr���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����zwere unexpected))r����r����fromkeysrL����reprr����r���r���r����+test_additionalProperties_multiple_failures ��s�����zGTestValidationErrorMessages.test_additionalProperties_multiple_failuresc�����������������C���s.���ddi}|�j�ddi|tjd�}|��d|��d�S�)N�constrZ���r*���r����r����z12 was expected�r����r����Draft6ValidatorrL���r����r���r���r���� test_const��s�����z&TestValidationErrorMessages.test_constc�����������������C���s4���dddii}|�j�di�g�g|tjd�}|��d|��d�S�)N�containsr����rZ���r����r����z4None of [2, {}, []] are valid under the given schemar����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���)�formats�thingc�����������������S���s���dS��NFr�����valuer���r���r���rG���+��rH���zQTestValidationErrorMessages.test_invalid_format_default_message.<locals>.<lambda>�formatZbla)r���r����format_checkerzis not a)r����checksr����rL���r����)r#����checkerr���rr���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�)Nr]���FrR���r^���)�^abc$�^def$)rR���r�����patternProperties�zebra�{���r����z,{} does not match any of the regexes: {}, {}r����r����i���)r�����fishz.{}, {} do not match any of the regexes: {}, {}r����)r����r����Draft4Validatorr���r����r����r����r���r���r����1test_additionalProperties_false_patternProperties8��s8������������zMTestValidationErrorMessages.test_additionalProperties_false_patternPropertiesc�����������������C���s"���|�j�ddtjd�}|��d|��d�S�)Nr5���Fr����z'False schema does not allow 'something')r����r���ru���rL���r����r���r���r����test_False_schemaV��s�����z-TestValidationErrorMessages.test_False_schemaN)r:���rl���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�������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 g�d ����|��|j��|��|jd��|��|j|d�d�d���|��|j|��|��|j |d�d���|��|j|��|��|jt g����|��|jt g����|��|jt g����|��|jt ddg���|��|jt ddg���|��|jt g�d����|��t|j�d��d�S�)N�����anyOfr��������rR���r^���r/���r���r����)r����r���r����)r����r/���rR���)r���r����r1���r0���r���r2���r���r-���r���r����assertIsNone�parent�pathr���� relative_path� absolute_pathr.����relative_schema_path�absolute_schema_path�context� sorted_errors�assertIsrt����r#���r���r���r���r3���r�����e1�e2r���r���r���� test_anyOfb��sb������ �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 g�d ����|��|j��|��|jd��|��|jdg��|��|jd��|��|j ddgi��|��|j|��|��|jt dg���|��|jt dg���|��|jt dg���|��|jt g�d����|��|jt g�d����|��|jt g�d����|��|j��d�S�) Nr*���r/���rR���rY���r]���r����r�����rR���r����r���)rR���r���rR���)r/���r����r*���r����)rR���r/���r����r*���r����)r���r����r1���r0���r���r2���r���r-���r���r���r����r����r����r���r����r����r.���r����r����r���r��r��rt���r��r���r���r���� test_type���sp������� �� �z$TestValidationErrorDetails.test_typec����������� ������C���s���ddgddd�}dddid did g�d�d�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����rR���r^���r����r����r����r����r����r����r����r*���r����r����) r���r����r0���r��r���r����r���r����r����r���) r#���r���r���r���r3���r��r���e3�e4r���r���r����test_single_nesting���s4������ z.TestValidationErrorDetails.test_single_nestingc�����������������C���s���ddddgid�dg}dddgddd gid ddid did�d�d�d�d�}t��|�}|�|�}t|�\}}}}} } |��|jtg����|��|jtdg���|��|jtddg���|��|jtg�d����|��| jtg�d����|��| jtddg���|��|jtdg���|��|jtddg���|��t|j�g�d���|��t|j�g�d���|��t| j�g�d���|��t| j�g�d���|��|j d��|��|j d��|��|j d��|��|j d��|��| j d ��|��| j d��d�S�)Nr/���r����r����)r*���r����r����r^���r]���r����r����rW����requiredTr����)r����r����r��)rR���r����r���r����)r/���r����r����)r/���r����r����r*���rR���r����)r����r����r����rR���)r����r����r����r����r����r��)r����r����r����r����r����r����)r����r����r*���r����) r���r����r0���r��r���r����r���r.���r1���r���)r#���r���r���r���r3���r��r��r ��r ��Ze5Ze6r���r���r����test_multiple_nesting��sV���� ����� ����z0TestValidationErrorDetails.test_multiple_nestingc�������������� ���C���s��dddddgddiddd d iid�d�d �giiddgdd d iid�}dddddddiid�id�i}t��|�}|�|�\}|��|jtdg���|��|jtg�d����|j\}|��|jtg�d����|��|jtg�d����|j\}|��|jtg�d����|��|jtg�d����d�S�)NZnoder����r]���r�����childrenrR���r^����^.*$�$refz#/definitions/node)rR���r����)r����r��)rR���r��r�����root)ZdefinitionsrR���r��r����r�����ab)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��r����r��r����)r���r����r0���r���r����r���r����r���)r#���r���r���r���r����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����rY���r�����rR���r����r*���rR���r�����r���r����r0���r��r���r����r���r����r#���r���r���r���r3���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����rR���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/���rY���r����r��r����r���rR���r����r��r��r���r���r����test_additionalItems���s����� z/TestValidationErrorDetails.test_additionalItemsc�����������������C���s����g�d�}i�gddd�d�}t��|�}|�|�}t|�\}}|��|jtdg���|��|jtdg���|��|jd��|��|jd ��d�S�) N)r*���r����r/���rY���r����r��r����r/���r����rR���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*���rZ���Z propertyNames�notr����z%r is not allowed for %r� r���ru���r0���r���r���rr���r����r���r.���)r#���r���r���r����errorr���r���r����test_propertyNames���s���� �z-TestValidationErrorDetails.test_propertyNamesc�����������������C���sp���ddiddid�}t��|�}|�d�\}|��|jd��|��|jd��|��|jtg����|��|jtg�d����d�S�)Nr����rZ���� ���)�if�then�13 was expected)r ��r!��r����r���r#���r���r���r��r���r���r����test_if_then���s����� z'TestValidationErrorDetails.test_if_thenc�����������������C���sp���ddiddid�}t��|�}|�d�\}|��|jd��|��|jd��|��|jtg����|��|jtg�d����d�S�)Nr����rZ���r��)r ���elser����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�)NFrZ���zFalse schema does not allow 12)r���ru���r0���r���rr���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����rR���rY���r��rB�����store��resolverr*���ZnotAnIntegerz''notAnInteger' is not of type 'integer') r���ru����RefResolverr0���r���rr���r���r-���r���r����r���r.���r���)r#����refr���r���r��r���r���r����test_ref-��s0������ ��z#TestValidationErrorDetails.test_refN)r:���rl���rm���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���sF���|���tj��&�|�j�ddt��ii��W�d�����n1�s80����Y��d�S�)Nr�����test)r����r ����SchemaErrorr!����check_schemar]���r"���r���r���r����test_invalid_propertiesM��s����z,MetaSchemaTestsMixin.test_invalid_propertiesc�����������������C���s@���|���tj�� �|�j�ddi��W�d�����n1�s20����Y��d�S�)Nr�����1)r����r ���r1��r!���r2��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!���r2��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����rZ���Nr6��r"���r���r���r����!test_enum_allows_non_unique_items^��s����z6MetaSchemaTestsMixin.test_enum_allows_non_unique_itemsN)r:���rl���rm���r3��r5��r7��r8��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�r%���)�validr_���r!���rv����r#���r���r���r���r���r����test_valid_instances_are_validh��s���� z1ValidatorTestMixin.test_valid_instances_are_validc�����������������C���s$���|�j�\}}|��|��|��|���d�S�r%���)�invalidrt���r!���rv���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!���r]���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�r%���)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���sn���dddi�}}t�jdi�||id�}|�jd|i|d�}|��tj���|�d���W�d�����n1�s`0����Y��d�S�)NZsomeCoolRefrR���rY���rB���r(��r��r*��)r���r,��r!���r����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��������������������sf���G���fdd�dt��}|��}ddi}���tj��$���j||d��d��W�d����n1�sX0����Y��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�)N�the refrR���rY����r���)�thisr-��r"���r���r���� resolving���s����zbValidatorTestMixin.test_it_delegates_to_a_legacy_ref_resolver.<locals>.LegacyRefResolver.resolvingN)r:���rl���rm���r���rF��r���r"���r���r����LegacyRefResolver���s���rG��r��rC��r*��N)r]���r����r ���r���r!���r����)r#���rG��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*���r^���)r_���r!���rS���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*���rW����rt���r!���rS���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�)NTrY���r\���rJ��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�)NrR���r^���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*���NrM��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����rR���r\���c�����������������S���s���t�|tttf�ot�|t��S�r%���)� isinstancerx����floatr����bool�r����r����r���r���r���rG������s��� �zGValidatorTestMixin.test_it_can_validate_with_decimals.<locals>.<lambda>�r���r/���g�������?r����r*���Tc�����������������S���s���g�|�] }|j��qS�r���r?��)rT���r��r���r���r���� <listcomp>���rH���zIValidatorTestMixin.test_it_can_validate_with_decimals.<locals>.<listcomp>) r���re���r!���r(����redefiner����r���r���r0���)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�r%���)r!���r����r����rZ��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�����n1�sr0����Y����|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����rY��r]��r^��)r���� ValueErrorr����r!���r����r����r ���r���r��r�����cause)r#���r����ra��r����cmr���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�)NrR���c�����������������S���s ���t�|t�S�r%����rQ��rx���rT��r���r���r���rG������rH���z@ValidatorTestMixin.test_non_string_custom_type.<locals>.<lambda>rU��r����)r]���r���re���r!���r(���rW��r����)r#���Znon_string_typer����Crazyr���r���r����test_non_string_custom_type���s���� ��z.ValidatorTestMixin.test_non_string_custom_typec�����������������C���st���t�j|�j|�jj�ddd���d�}|��tj��"}|ddi��d��W�d����n1�sT0����Y��|�� d t |j���dS�) z� A tuple instance properly formats validation errors for uniqueItems. See https://github.com/Julian/jsonschema/pull/224 rW���c�����������������S���s ���t�|t�S�r%���)rQ���tuplerT��r���r���r���rG������rH���zNValidatorTestMixin.test_it_properly_formats_tuples_in_errors.<locals>.<lambda>rU��ZuniqueItemsT)r/���r/���Nz(1, 1) has non-unique elements)r���re���r!���r(���rW��r����r ���r���r����rL���rw���r����)r#���ZTupleValidatorr����r���r���r����)test_it_properly_formats_tuples_in_errors���s������0z<ValidatorTestMixin.test_it_properly_formats_tuples_in_errorsN)r:���rl���rm���r<��r>��r@��rA��rB��rH��rI��rK��rL���unittestZskipIfr���rN��rP��rX��r[��r\��re��rh��rj��r���r���r���r���r9��g��s$��� r9��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���sN���|���tj��}|�j�d��W�d�����n1�s.0����Y��|��dt|j���d�S�)NTzTrue is not of type�r����r ���r1��r!���r2��rL���rw���r����r����r���r���r����test_True_is_not_a_schema��s����*z-AntiDraft6LeakMixin.test_True_is_not_a_schemac�����������������C���sN���|���tj��}|�j�d��W�d�����n1�s.0����Y��|��dt|j���d�S�)NFzFalse is not of typerm��r����r���r���r����test_False_is_not_a_schema��s����*z.AntiDraft6LeakMixin.test_False_is_not_a_schemai��c�����������������C���s^���t��di��}|��t��$}|�jd|d��d��W�d�����n1�s@0����Y��|��|jtj ��d�S�)NrB���Tr*��rZ���� r���r,��r����� Exceptionr!���r����ZassertNotIsInstancer����r ���r����r#���r+��r����r���r���r����5test_True_is_not_a_schema_even_if_you_forget_to_check��s����2zIAntiDraft6LeakMixin.test_True_is_not_a_schema_even_if_you_forget_to_checkc�����������������C���s^���t��di��}|��t��$}|�jd|d��d��W�d�����n1�s@0����Y��|��|jtj ��d�S�)NrB���Fr*��rZ���rp��rr��r���r���r����6test_False_is_not_a_schema_even_if_you_forget_to_check��s����2zJAntiDraft6LeakMixin.test_False_is_not_a_schema_even_if_you_forget_to_checkN)r:���rl���rm����__doc__rn��ro��rk���skipr���rs��rt��r���r���r���r���rl�����s��� rl��c�������������������@���sF���e�Zd�ZejZi�i�fZddidfZdd��Zdd��Z dd ��Z d d��ZdS�) �TestDraft3ValidatorrR���rY���r*���c�����������������C���s���|���ddi�}|�t����d�S��NrR����any)r!���r����r]���rZ��r���r���r����#test_any_type_is_valid_for_type_any��s����z7TestDraft3Validator.test_any_type_is_valid_for_type_anyc�����������������C���sp���t�j|�j|�jj�ddd���d�}|ddi�}|�d��|��tj���|�d��W�d����n1�sb0����Y��dS�) z( Sigh, because why not. ry��c�����������������S���s ���t�|t�S�r%���rf��rT��r���r���r���rG���*��rH���zBTestDraft3Validator.test_any_type_is_redefinable.<locals>.<lambda>rU��rR���rZ���r*���N) r���re���r!���r(���rW��r����r����r ���r���)r#���rg��r���r���r���r����test_any_type_is_redefinable#��s������ z0TestDraft3Validator.test_any_type_is_redefinablec�����������������C���s"���|���|��i���t��ddi���d�S�rx��)r_���r!���rv���r]���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�)NTrX���rR���ry��)r_���r!���rS���rv���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)r:���rl���rm���r���r����r!���r:��r=��rz��r{��r|��r}��r���r���r���r���rw����s���rw��c�������������������@���s&���e�Zd�ZejZi�i�fZddidfZdS�)�TestDraft4ValidatorrR���rY���r*���N)r:���rl���rm���r���r����r!���r:��r=��r���r���r���r���r~��:��s���r~��c�������������������@���s&���e�Zd�ZejZi�i�fZddidfZdS�)�TestDraft6ValidatorrR���rY���r*���N)r:���rl���rm���r���r����r!���r:��r=��r���r���r���r���r��@��s���r��c�������������������@���s&���e�Zd�ZejZi�i�fZddidfZdS�)�TestDraft7ValidatorrR���rY���r*���N)r:���rl���rm���r���ru���r!���r:��r=��r���r���r���r���r���F��s���r���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�)N�$schema�&http://json-schema.org/draft-03/schema�'http://json-schema.org/draft-03/schema#)r��r���� validator_forr����r+���r���r���r����test_draft_3M��s������zTestValidatorFor.test_draft_3c�����������������C���s<���ddi}|���t�|�tj��ddi}|���t�|�tj��d�S�)Nr����&http://json-schema.org/draft-04/schema�'http://json-schema.org/draft-04/schema#)r��r���r���r����r+���r���r���r����test_draft_4Z��s������zTestValidatorFor.test_draft_4c�����������������C���s<���ddi}|���t�|�tj��ddi}|���t�|�tj��d�S�)Nr����&http://json-schema.org/draft-06/schema�'http://json-schema.org/draft-06/schema#)r��r���r���r����r+���r���r���r����test_draft_6g��s������zTestValidatorFor.test_draft_6c�����������������C���s<���ddi}|���t�|�tj��ddi}|���t�|�tj��d�S�)Nr����&http://json-schema.org/draft-07/schema�'http://json-schema.org/draft-07/schema#)r��r���r���ru���r+���r���r���r����test_draft_7t��s������zTestValidatorFor.test_draft_7c�����������������C���s���|���t�d�tj��d�S�)NT�r��r���r���Z_LATEST_VERSIONr"���r���r���r���� test_True���s�����zTestValidatorFor.test_Truec�����������������C���s���|���t�d�tj��d�S�r����r���r"���r���r���r���� test_False���s�����zTestValidatorFor.test_Falsec�����������������C���s6���t�jddiddd��d�}ddi}|��t��|�|��d�S�)Nr=���r@���Z12c�����������������S���s���|���dd�S�rA���rC���rE���r���r���r���rG������rH���z8TestValidatorFor.test_custom_validator.<locals>.<lambda>rI���r����r���r ���r��r����r#���r!���r���r���r���r����test_custom_validator���s������z&TestValidatorFor.test_custom_validatorc�����������������C���s0���t�jddidd�}ddi}|��t��|�|��d�S�)Nr���rO���Z13r7���r���r���r���r���r���r����test_custom_validator_draft6���s������z-TestValidatorFor.test_custom_validator_draft6c�����������������C���s���|���t�i��tj��d�S�r%���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���r���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.r���Z unknownSchema)rz���rr���r{���r|���r���r���)r~���r���r����r����rl���r����r���r���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���r���)r���r���rt���rq���r"���r���r���r����0test_does_not_warn_if_meta_schema_is_unspecified���s����zATestValidatorFor.test_does_not_warn_if_meta_schema_is_unspecifiedN)r:���rl���rm���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���L��s��� r���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�)Nr2��)�patch�appendr���r����r���)r#���r���r!����resultr���r���r���� assertUses���s����zTestValidate.assertUsesc�����������������C���s,���|�j�dditjd��|�j�dditjd��d�S�)Nr���r����r���r!���r���)r���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�)Nr���r���r���r���)r���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�)Nr���r���r���r���)r���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�)Nr���r���r���r����r���r���ru���r"���r���r���r����test_draft7_validator_is_chosen���s������z,TestValidate.test_draft7_validator_is_chosenc�����������������C���s���|�j�i�tjd��d�S�)Nr���r���r"���r���r���r����$test_draft7_validator_is_the_default���s����z1TestValidate.test_draft7_validator_is_the_defaultc�����������������C���sR���|���tj�� }t�dddi��W�d�����n1�s20����Y��|��t|j�d��d�S�)NrZ���rR���r^���z3(?s)Failed validating u?'.*' in schema.*On instance)r����r ���r���r���r�����assertRegexpMatchesrw���r����r����r���r���r����test_validation_error_message���s����.�z*TestValidate.test_validation_error_messagec�����������������C���sR���|���tj�� }t�dddi��W�d�����n1�s20����Y��|��t|j�d��d�S�)NrZ���rR���z5(?s)Failed validating u?'.*' in metaschema.*On schema)r����r ���r1��r���r����r���rw���r����r����r���r���r����test_schema_error_message���s����.�z&TestValidate.test_schema_error_messagec�����������������C���sb���dddiddigi}|���tj��}t�d|��W�d�����n1�sB0����Y��|��dt|j���d�S�)NZoneOfrR���r^���rW���rZ���z12 is not of type)r����r ���r���r���r����rL���rw���r����)r#���r���r����r���r���r����test_it_uses_best_match��s����*z$TestValidate.test_it_uses_best_matchN)r:���rl���rm���r���r���r���r���r���r���r���r���r���r���r���r���r���r������s���r���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�)$�TestRefResolverrB���zfoo://storedZstoredr���c�����������������C���s.���i�|�_�|�j|�ji|�_t�|�j|�j�|�j�|�_d�S�r%���)�referrer� stored_uri� stored_schemar)��r���r,���base_urir+��r"���r���r���r���r$�����s �����zTestRefResolver.setUpc��������������������sd���t�jjd�}�����jd��fdd�����j�|��}W�d�����n1�sF0����Y�����|t�jj��d�S�)Nr=���Zresolve_remotec���������������������s �������d�S�)NzShould not have been called!)r_��)r����r����r"���r���r���rG�����rH���zXTestRefResolver.test_it_does_not_retrieve_schema_urls_from_the_network.<locals>.<lambda>)r���r����r'���r���r+��rF��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���sZ���d}dt���i|�jd<�|�j�|��&}|��||�jd�d���W�d�����n1�sL0����Y��d�S�)Nz#/properties/foor*���r����)r]���r���r+��rF��r���r���r���r���r����test_it_resolves_local_refs%��s����z+TestRefResolver.test_it_resolves_local_refsc�����������������C���s����dddid�}t�jj|dd��d�}|�d�� }|��||d ���W�d�����n1�sR0����Y��|�d �� }|��||d ���W�d�����n1�s�0����Y��d�S�)Nzhttp://bar/schema#r*���r����)r=���r����c�����������������S���s���|���dd�S�rA���rC���rj���r���r���r���rG���/��rH���zETestRefResolver.test_it_resolves_local_refs_with_id.<locals>.<lambda>�rJ���z#/ar����zhttp://bar/schema#/a)r���r,���from_schemarF��r����r#���r���r+��r���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�����n1�s20����Y��ddi|�j�jd<�|�j��d��}|��|d��W�d�����n1�sz0����Y��d�S�)Nr*���rZ���Z cached_refzcached_ref#/foo)r+��rF��r���r��r���r)��r���)r#���r���r���r���r����test_it_retrieves_stored_refs6��s ����,z-TestRefResolver.test_it_retrieves_stored_refsc�����������������C���s|���d}ddi}dt�jv�r.|��t�jjdt�jd���td|i�t�jd<�|�j�|��}|��|d��W�d�����n1�sn0����Y��d�S�)N�http://bar#bazr����rZ����requests� http://bar)r����r����r����__setitem__�ReallyFakeRequestsr+��rF��r���)r#���r-��r���r���r���r���r����,test_it_retrieves_unstored_refs_via_requests>��s���� �z<TestRefResolver.test_it_retrieves_unstored_refs_via_requestsc��������������������s����d}ddi��dt�jv�r.��t�jjdt�jd���d�t�jd<�t���fdd��}��ttdtj��|t_�j� |��}W�d�����n1�s�0����Y���� |d��d�S�)Nr���r����rZ���r���c�����������������3���s&������|�d��tt�����d��V��d�S�)Nr����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)r����r����r���r���r����setattrr���r���r+��rF��r���)r#���r-��r���r���r���r���r����+test_it_retrieves_unstored_refs_via_urlopenK��s���� � z;TestRefResolver.test_it_retrieves_unstored_refs_via_urlopenc�����������������C���s����t�jddd��0}|��tj|j��t�ddi|��W�d�����n1�sD0����Y��d�t |j��}|�j �|��}|��|d��W�d�����n1�s�0����Y��d�S�)NFZwt)�delete�moder*���r����z file://{}#foo) �tempfileZNamedTemporaryFiler����os�remover����r����dumpr����r ���r+��rF��r���)r#���Ztempfr-��r���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�����n1�sd0����Y��|�d��}|��||��W�d�����n1�s�0����Y��|�d��}|��||��W�d�����n1�s�0����Y��|�d��}|��||��W�d�����n1��s0����Y��d�S�) Nr=���r*���c�����������������S���s���|���dd�S�rA���rC���rj���r���r���r���rG���n��rH���zPTestRefResolver.test_it_can_construct_a_base_uri_from_a_schema.<locals>.<lambda>r���rB����#zfoo#�r���r,��r���r���r���Zresolution_scoperF��r���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���s����i�}t�j�|�}|��|jd��|��|jd��|�d��}|��||��W�d�����n1�sX0����Y��|�d��}|��||��W�d�����n1�s�0����Y��d�S�)NrB���r���r���r���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��������������������sj�������fdd�}ddi�d��t�jdi�d|id�}|�����}��|���W�d�����n1�s\0����Y��d�S�)Nc��������������������s������|������S�r%���rD��r����r-��r���r#���r���r����handler���s����z@TestRefResolver.test_custom_uri_scheme_handlers.<locals>.handlerr*���r����� foo://barrB�����handlers)r���r,��rF��r���)r#���r���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�����n1�sP0����Y��|�|���W�d�����n1�sz0����Y��d�S�)Nc��������������������s,���z ������W�S��ty&�����d��Y�n0�d�S�)Nz#Response must not have been cached!�r9���� IndexErrorr_��r�����responser#���r���r���r������s���� z5TestRefResolver.test_cache_remote_on.<locals>.handlerr���rB���Tr*����Zcache_remoter����r]���r���r,��rF���r#���r���r-��r+��r���r���r����test_cache_remote_on���s�����z$TestRefResolver.test_cache_remote_onc��������������������s^���t���g�����fdd�}d}tjdi�dd|id�}|�|���W�d�����n1�sP0����Y��d�S�)Nc��������������������s,���z ������W�S��ty&�����d��Y�n0�d�S�)NzHandler called twice!r���r���r���r���r���r������s���� z6TestRefResolver.test_cache_remote_off.<locals>.handlerr���rB���Fr*���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}|�|���|��d��W�d�����n1�sd0����Y��W�d�����n1�s�0����Y��|��|j t������d�S�) NzOh no! What's this?c��������������������s������d�S�r%���r���r����r��r���r���r������s����zTTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_error.<locals>.handlerr���rB���r*���r���zShouldn't get this far!) rb��r���r,��r����r ����RefResolutionErrorrF��r_��r���r����)r#���r���r-��r+���errr���r���r����3test_if_you_give_it_junk_you_get_a_resolution_error���s����FzCTestRefResolver.test_if_you_give_it_junk_you_get_a_resolution_errorc�����������������C���s^���t��di��}|����|��tj��}|����W�d�����n1�s>0����Y��|��dt|j���d�S�)NrB���zFailed to pop the scope) r���r,��Z pop_scoper����r ���r���rL���rw���r����)r#���r+���excr���r���r����.test_helpful_error_message_on_failed_pop_scope���s ����&z>TestRefResolver.test_helpful_error_message_on_failed_pop_scopeN)r:���rl���rm���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�����������������C���s���dd��}t�|�|d�S�)Nc�����������������S���s ���dd��|�j�D��dd��|�jD��fS�)Nc�����������������S���s���g�|�]}t�|��qS�r����rw���r����r���r���r���rV�����rH���z.sorted_errors.<locals>.key.<locals>.<listcomp>c�����������������S���s���g�|�]}t�|��qS�r���r���r����r���r���r���rV�����rH���)r����r.���r���r���r���r����key���s�����zsorted_errors.<locals>.key)r���)r����)r3���r���r���r���r���r�����s����r��c�������������������@���s���e�Zd�Ze���Zdd��ZdS�)r���c�����������������C���s2���|�j��|�}|d�u�r$tdt|����tt�|��S�)Nz Unknown URL: )� _responsesrD���rb��r�����_ReallyFakeJSONResponser���r���)r#���r���r���r���r���r���rD������s����zReallyFakeRequests.getN)r:���rl���rm����attr�ibr���rD���r���r���r���r���r������s���r���c�������������������@���s���e�Zd�Ze���Zdd��ZdS�)r���c�����������������C���s���t��|�j�S�r%���)r����loads� _responser"���r���r���r���r������s����z_ReallyFakeJSONResponse.jsonN)r:���rl���rm���r���r���r���r���r���r���r���r���r������s���r���)0�collectionsr���� contextlibr���Zdecimalr����ior���rk��r���r���r���r����r���Ztwisted.trial.unittestr���r���Z jsonschemar���r ���r ���r���Zjsonschema.compatr���r ���Zjsonschema.tests._helpersr���r���r���rn���r����r����r����r]���r/��r9��rl��rw��r~��r��r���r���r���r���r��rF���r���r���r���r���r���r����<module>���sV�����]"�/���o� sN�;