HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/jsonschema/tests/__pycache__/test_format.cpython-310.pyc
o

>��]��@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|dkrt�t�)N�bang)�BANG�BOOM��thing�r�>/usr/lib/python3/dist-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)r�assertFalse�checkers��self�checkerrrr
�test_it_can_validate_no_formatss
z1TestFormatChecker.test_it_can_validate_no_formatscCs<|�t��tdgd�Wd�dS1swYdS)Nzo noesr)�assertRaises�KeyErrorr)rrrr
�.test_it_raises_a_key_error_for_unknown_formatss"�z@TestFormatChecker.test_it_raises_a_key_error_for_unknown_formatscCsFttj�}|�tjjd�t�d�t�|�tjt|tdfd��dS�Nrr)r)�dictrr�
addCleanup�pop�
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�checksrr rrrrrr
�test_it_can_register_checkers's�z/TestFormatChecker.test_it_can_register_checkerscCs�t�}|jdtt�d�t�|�t��}|jddd�Wd�n1s%wY|�|j	j
t�|�|j	jt�|�tt���|jddd�Wd�dS1sTwYdS)Nr��raises���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�n1s)wY|�|j	j
t�|�|j	jt�dS)Nrr%r*)�format_checkerr	)
rr#�
ValueErrorrrrr�validater-r.r/r	r0)rr�	validatorr1rrr
�7test_format_error_causes_become_validation_error_causes=s�zITestFormatChecker.test_format_error_causes_become_validation_error_causescCsDt�}|�t��|jddd�Wd�dS1swYdS)Nznot-an-ipv4�ipv4r()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r�foocS�dS�NTrr
rrr
�<lambda>S�z-TestFormatChecker.test_repr.<locals>.<lambda>�barcSr;r<rr
rrr
r=Tr>�bazcSr;r<rr
rrr
r=Ur>z.<FormatChecker checkers=['bar', 'baz', 'foo']>)rr#r �reprrrrr
�	test_reprQs
�zTestFormatChecker.test_reprN)�__name__�
__module__�__qualname__rrr"r$r2r7r9rBrrrr
rs		rN)�__doc__�unittestr�
jsonschemarrr�jsonschema.validatorsrr4r	�ZeroDivisionErrorrrrrrrr
�<module>s