Your IP : 3.147.77.119


Current Path : /opt/alt/python37/lib/python3.7/site-packages/jsonschema/tests/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/jsonschema/tests/__pycache__/test_cli.cpython-37.pyc

B

�pSew�@s�ddlmZddlZddlZddlZddlmZmZmZm	Z	ddl
mZddlm
Z
dd�ZGdd	�d	e�ZGd
d�de�ZdS)�)�TestCaseN)�Draft4Validator�ValidationError�cli�__version__)�NativeIO)�SchemaErrorcs$tt����G�fdd�dt�}|S)Ncs(eZdZdd�Z�fdd�Zdd�ZdS)z%fake_validator.<locals>.FakeValidatorc_sdS)N�)�self�args�kwargsr	r	�J/opt/alt/python37/lib/python3.7/site-packages/jsonschema/tests/test_cli.py�__init__sz.fake_validator.<locals>.FakeValidator.__init__cs�r���SgS)N)�pop)r
�instance)�errorsr	r
�iter_errorssz1fake_validator.<locals>.FakeValidator.iter_errorscSsdS)Nr	)r
�schemar	r	r
�check_schemasz2fake_validator.<locals>.FakeValidator.check_schemaN)�__name__�
__module__�__qualname__rrrr	)rr	r
�
FakeValidatorsr)�list�reversed�object)rrr	)rr
�fake_validatorsrc@s:eZdZe�ZdZdZdd�Zdd�Zdd�Z	d	d
�Z
dS)�
TestParserzfoo.jsonzschema.jsoncCs|jt_|�ttd�dS)N�open)�	fake_openrrZ
addCleanup�delattr)r
r	r	r
�setUp#szTestParser.setUpcCs>||jkrd}n ||jkr i}n|�d�|��tt�|��S)N�zWhat is {!r})�
instance_file�schema_fileZfail�formatr�json�dumps)r
�path�contentsr	r	r
r's

zTestParser.fake_opencCs.t�ddd|j|jg�}|�|d|j�dS)Nz--validatorz2jsonschema.tests.test_cli.TestParser.FakeValidatorz
--instance�	validator)r�
parse_argsr#r$�assertIsr)r
�	argumentsr	r	r
�2test_find_validator_by_fully_qualified_object_name0s
z=TestParser.test_find_validator_by_fully_qualified_object_namecCs,t�ddd|j|jg�}|�|dt�dS)Nz--validatorrz
--instancer*)rr+r#r$r,r)r
r-r	r	r
�!test_find_validator_in_jsonschema;s

z,TestParser.test_find_validator_in_jsonschemaN)rrrrrr#r$r!rr.r/r	r	r	r
rs	rc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestCLIc	CsZt�t�}}|�t��8tjtdddiddiddigidgd	d
�||d�WdQRXdS)NZanyOfZminimum��type�string�requiredT�z{error.message})r*r�	instances�error_format)�stdout�stderr)rZassertRaisesrr�runr)r
r8r9r	r	r
�#test_draft3_schema_draft4_validatorGs
z+TestCLI.test_draft3_schema_draft4_validatorcCsXt�t�}}tjt�idgdd�||d�}|�|���|�|���|�|d�dS)Nr5z{error.message})r*rr6r7)r8r9r)rrr:r�assertFalse�getvalue�assertEqual)r
r8r9�	exit_coder	r	r
�test_successful_validation[sz"TestCLI.test_successful_validationcCsjtddd�}t�t�}}tjt|g�idgdd�||d�}|�|���|�|��d�|�|d�dS)NzI am an error!r5)rz"{error.instance} - {error.message})r*rr6r7)r8r9z1 - I am an error!)rrrr:rr<r=r>)r
�errorr8r9r?r	r	r
�test_unsuccessful_validationksz$TestCLI.test_unsuccessful_validationcCs�tddd�tddd�g}tddd�g}t�t�}}tjt||�iddgdd�||d	�}|�|���|�|��d
�|�|d�dS)N�9r5)r�8�7�z#{error.instance} - {error.message}	)r*rr6r7)r8r9z1 - 9	1 - 8	2 - 7	)rrrr:rr<r=r>)r
Zfirst_errorsZ
second_errorsr8r9r?r	r	r
�/test_unsuccessful_validation_multiple_instances|s
z7TestCLI.test_unsuccessful_validation_multiple_instancescCs8tjtjdddgtjd�}|�d���}|�|t�dS)Nz-m�
jsonschemaz	--version)r9zutf-8)	�
subprocess�check_output�sys�
executable�STDOUT�decode�stripr>r)r
�versionr	r	r
�test_version�s

zTestCLI.test_versionN)rrrr;r@rBrGrQr	r	r	r
r0Fs
r0)Zunittestrr&rIrKrHrrrrZjsonschema.compatrZjsonschema.exceptionsrrrr0r	r	r	r
�<module>s)

?>