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



LX@sddlZddlmZmZmZmZddlmZidddddZddZ	dd	Z
ddd
dddddZddd
d
dZfddZ
ddZddZddZddddZdS)N)errors	ValidatorSchemaError
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. Nmessage)rrpytestZraises)	exceptiondocumentschema	validatormsgZexcinfor/__init__.pyassert_exception	srcGstt|dS)zS Tests whether a validation raises an exception due to a malformed
        schema. N)rr)argsrrrassert_schema_errorsrcGstt|dS)zU Tests whether a validation raises an exception due to a malformed
        document. N)rr)rrrrassert_document_errorsrFc	Csf|dkrtt}||||}t|ts?t|sLt|j}|dk	oj|dk	stt|dk	o|dk	st|dk	o|dkst|dk	r+t|dkstt|||dk	rbt|djt|kstt	|dj|n7|dk	rbt|t|ksUtt	|||S)z# Tests whether a validation fails. Nr)
rr
isinstanceboolAssertionError_errorslenassert_has_errorchild_errorsassert_has_errors)	r
rrupdateerrorrrresultZ
actual_errorsrrrassert_fail#s&
	
%
r cCsX|dkrtt}||||}t|ts?t|sTt|jdS)z& Tests whether a validation succeeds. N)rrrrrr)r
rrrrrrrassert_success@sr!cCs{t|ts|f}t|ts0|f}t|tjsHtx,t|D]\}}t|tjsyty|j|kst|j|kst|j	|j	kst|j
|j
kst|j|kst|js	|j
|ks	tWn&tk
rYqUtk
r2YqUXPqUWtdjd|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_pathschema_pathcodeinfo
constraintr)rtuplerZ	ErrorListr	enumerateZValidationErrorZ
document_pathr"r#Zruler%Zis_group_errorr$	Exceptionformathex)rZd_pathZs_pathZ	error_defr%r$irrrrrJs2			

	rcCsLt|tstx0|D](}t|ts7tt||qWdS)N)rlistrr&r)rZ_exp_errorsrrrrrrs
rcOscyt|||Wn<tk
r(Yn7tk
rR}z|WYdd}~Xn
XtddS)NzAn unexpected error occurred.)rrr()rrkwargserrrassert_not_has_errorys
r/cCs/t||id||dftj|fdS)Nrtype)r rZBAD_TYPE)ZfieldZ	data_typevaluerrrassert_bad_typesr2cCsA|dkrtt}t||||j|ks=tdS)N)rrr!r
r)r
Zexpectedrrrrrassert_normalizedsr3)rZcerberusrrrrZcerberus.tests.conftestrrrrr r!rrr/r2r3rrrr<module>s"	
	
(
Back to Directory File Manager