U `7 @stddlmZddlZddlmZmZddlmZddZddZ e d d d d Z e d d d dZ ddZ dS))markN) assert_failassert_success) sample_schemacsTGfdddtjdjks$tddddididd}tdd gi|d dS) Ncs&eZdZfddZddZZS)z=test_contextual_data_preservation..InheritedValidatorcs(d|kr|d|_t|j||dS)N working_dir)rsuper__init__)selfargskwargs)InheritedValidator __class__R/opt/alt/python38/lib/python3.8/site-packages/cerberus/tests/test_customization.pyr s zFtest_contextual_data_preservation..InheritedValidator.__init__cSs|jr dSdS)NTrr valuerrr_validate_type_testszQtest_contextual_data_preservation..InheritedValidator._validate_type_test)__name__ __module__ __qualname__rr __classcell__rr )r rr sr Ztestlisttype)rschemaz/tmprfoo) validator)cerberus ValidatortypesAssertionErrorr)vrrr!test_contextual_data_preservation s r#cCs2Gdddtj}d|jks td|jks.tdS)Nc@seZdZddZddZdS)z/test_docstring_parsing..CustomValidatorcSsdS)z{'type': 'zap'}Nr)r Zargumentfieldrrrr _validate_foosz=test_docstring_parsing..CustomValidator._validate_foocSsdS)z Test the barreness of a value. The rule's arguments are validated against this schema: {'type': 'boolean'} Nrrrrr _validate_bar"sz=test_docstring_parsing..CustomValidator._validate_barN)rrrr%r&rrrrCustomValidatorsr'rZbar)rrZvalidation_rulesr!)r'rrrtest_docstring_parsingsr(rule)Z check_withrcCsXGdddtj}|d|diid}tddi|dtddi|dd tjjdd fd dS) Nc@seZdZddZdS)z+test_check_with_method..MyValidatorcSs|d@s||ddSNMust be an odd numberZ_errorr r$rrrr_check_with_oddity4sz>test_check_with_method..MyValidator._check_with_oddityN)rrrr/rrrr MyValidator3sr0amountoddityrr+documentrrr,r5rerrorrrrrerrorsZCUSTOMr)r0r"rrrtest_check_with_method0sr=cCsXGdddtj}|d|diid}tddi|dtddi|dd tjjdd fd dS) Nc@seZdZddZdS)z*test_validator_method..MyValidatorcSs|d@s||ddSr*r-r.rrr_validator_oddityEsz.MyValidator._validator_oddityN)rrrr>rrrrr0Dsr0r1r2r3r+r4r6rr7r8r:r<rrrtest_validator_methodBsr?cCsHGdddtj}|td}|jddids0t|jddidrDtdS)Nc@s"eZdZdZejjjddZdS)zWtest_schema_validation_can_be_disabled_in_schema_setter..NonvalidatingValidatorzD Skips schema validation to speed up initialization cSsF|dkrd|_n2|jr||_n$t|tjjr4||_ntj||_dS)N)Z_schemaZis_child isinstancerrZDefinitionSchemaZUnvalidatedSchema)r rrrrrXsz^test_schema_validation_can_be_disabled_in_schema_setter..NonvalidatingValidator.schemaN)rrr__doc__rrrsetterrrrrNonvalidatingValidatorSsrCr3Z an_integerr+)r5a)rrrZvalidater!)rCr"rrr7test_schema_validation_can_be_disabled_in_schema_setterRs rE)ZpytestrrZcerberus.testsrrZcerberus.tests.conftestrr#r(Z parametrizer=r?rErrrrs