name : test_format.cpython-39.pyc
a

��s]��@s\dZddlmZddlmZmZmZddlmZe	d�Z
ed�Zdd�Z
Gd	d
�d
e�ZdS)zP
Tests for the parts of jsonschema related to the :validator:`format` property.
�)�TestCase)�FormatError�ValidationError�
FormatChecker)�Draft4ValidatorzBoom!zBang!cCs|dkrt�t�dS)N�bang)�BANG�BOOM��thing�r�@/usr/lib/python3.9/site-packages/jsonschema/tests/test_format.py�boomsrc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�TestFormatCheckercCstdd�}|�|j�dS)Nr��formats)rZassertFalse�checkers��self�checkerrrr
�test_it_can_validate_no_formatss
z1TestFormatChecker.test_it_can_validate_no_formatscCs:|�t��tdgd�Wd�n1s,0YdS)Nzo noesr)�assertRaises�KeyErrorr)rrrr
�.test_it_raises_a_key_error_for_unknown_formatss[email protected]_it_raises_a_key_error_for_unknown_formatscCsFttj�}|�tjjd�t�d�t�|�tjt|tdfd��dS�Nrr)r)�dictrrZ
addCleanup�popZ
cls_checksr�assertEqual)r�originalrrr
�!test_it_can_register_cls_checkerss
�z3TestFormatChecker.test_it_can_register_cls_checkerscCs4t�}|�d�t�|�|jttjtdfd��dSr)r�checksrrrrrrrr
�test_it_can_register_checkers's�z/TestFormatChecker.test_it_can_register_checkerscCs�t�}|jdtt�d�t�|�t��}|jddd�Wd�n1sJ0Y|�|j	j
t�|�|j	jt�|�tt���|jddd�Wd�n1s�0YdS)Nr�Zraises���instance�formatr)
rr �typer	rrr�check�assertIs�	exception�cause�	__cause__r)rr�cmrrr
�!test_it_catches_registered_errors/s,z3TestFormatChecker.test_it_catches_registered_errorscCs�t�}|jdtd�t�tddi|d�}|�t��}|�d�Wd�n1sR0Y|�|j	j
t�|�|j	jt�dS)Nrr"r&)Zformat_checkerr	)
rr �
ValueErrorrrrrZvalidater)r*r+r	r,)rrZ	validatorr-rrr
�7test_format_error_causes_become_validation_error_causes=s(zITestFormatChecker.test_format_error_causes_become_validation_error_causescCsBt�}|�t��|jddd�Wd�n1s40YdS)Nznot-an-ipv4Zipv4r$)rrrr(rrrr
�'test_format_checkers_come_with_defaultsHsz9TestFormatChecker.test_format_checkers_come_with_defaultscCsTtdd�}|�d�dd��|�d�dd��|�d�d	d��|�t|�d
�dS)NrrZfoocSsdS�NTrr
rrr
�<lambda>S�z-TestFormatChecker.test_repr.<locals>.<lambda>ZbarcSsdSr2rr
rrr
r3Tr4ZbazcSsdSr2rr
rrr
r3Ur4z.<FormatChecker checkers=['bar', 'baz', 'foo']>)rr r�reprrrrr
�	test_reprQs
�zTestFormatChecker.test_reprN)�__name__�
__module__�__qualname__rrrr!r.r0r1r6rrrr
rs		rN)�__doc__ZunittestrZ
jsonschemarrrZjsonschema.validatorsrr/r	�ZeroDivisionErrorrrrrrrr
�<module>s

© 2025 Cubjrnet7