Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/cerberus/tests/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/cerberus/tests/__pycache__/__init__.cpython-35.pyc



L�X��@s�ddlZddlmZmZmZmZddlmZiddddd�Zdd�Z	dd	�Z
ddd
ddddd�Zddd
d
d�Zfdd�Z
dd�Zdd�Zdd�Zdddd�ZdS)�N)�errors�	Validator�SchemaError�
DocumentError)�
sample_schemac
Cs}|dkrtt�}|dkrMtj|��}|||�WdQRXn,tj|d|��}|||�WdQRXdS)z{ Tests whether a specific exception is raised. Optionally also tests
        whether the exception message is as expected. N�message)rr�pytestZraises)�	exception�document�schema�	validator�msgZexcinfo�r�H/opt/alt/python35/lib/python3.5/site-packages/cerberus/tests/__init__.py�assert_exception	srcGstt|�dS)zS Tests whether a validation raises an exception due to a malformed
        schema. N)rr)�argsrrr�assert_schema_errorsrcGstt|�dS)zU Tests whether a validation raises an exception due to a malformed
        document. N)rr)rrrr�assert_document_errorsrFc	Csf|dkrtt�}||||�}t|t�s?t�|sLt�|j}|dk	oj|dk	stt�|dk	o�|dk	s�t�|dk	o�|dks�t�|dk	r+t|�dks�t�t||�|dk	rbt|dj�t|�kst�t	|dj|�n7|dk	rbt|�t|�ksUt�t	||�|S)z# Tests whether a validation fails. N�r)
rr�
isinstance�bool�AssertionError�_errors�len�assert_has_error�child_errors�assert_has_errors)	r
rr�update�errorrr�resultZ
actual_errorsrrr�assert_fail#s&
	
%
r cCsX|dkrtt�}||||�}t|t�s?t�|sTt|j��dS)z& Tests whether a validation succeeds. N)rrrrrr)r
rrrrrrr�assert_success@sr!cCs{t|t�s|f}t|t�s0|f}t|tj�sHt�x,t|�D]�\}}t|tj�syt�y�|j|ks�t�|j|ks�t�|j	|j	ks�t�|j
|j
ks�t�|j|ks�t�|js	|j
|ks	t�Wn&tk
rYqUtk
r2�YqUXPqUWtdjd|d|dt|j	�d|d|d|���|S)Nz�
        Error with properties:
          document_path={doc_path}
          schema_path={schema_path}
          code={code}
          constraint={constraint}
          info={info}
        not found in errors:
        {errors}
        Zdoc_path�schema_path�code�info�
constraintr)r�tupler�	ErrorListr�	enumerate�ValidationError�
document_pathr"r#�ruler%�is_group_errorr$�	Exception�format�hex)rZd_pathZs_pathZ	error_defr%r$�irrrrrJs2			

	rcCsLt|t�st�x0|D](}t|t�s7t�t||�qWdS)N)r�listrr&r)rZ_exp_errorsrrrrrrs
rcOscyt|||�Wn<tk
r(Yn7tk
rR}z|�WYdd}~Xn
Xtd��dS)NzAn unexpected error occurred.)rrr-)rr�kwargs�errr�assert_not_has_errorys
r4cCs/t||id||dftj|f�dS)Nr�type)r r�BAD_TYPE)�field�	data_type�valuerrr�assert_bad_type�sr:cCsA|dkrtt�}t|||�|j|ks=t�dS)N)rrr!r
r)r
Zexpectedrrrrr�assert_normalized�sr;)r�cerberusrrrrZcerberus.tests.conftestrrrrr r!rrr4r:r;rrrr�<module>s"	
	
(