
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
U
    `7                     @   st   d dl mZ d dlZd dlmZmZ d dlmZ dd Zdd Z	e
d	d
dd Ze
d	d
dd Zdd ZdS )    )markN)assert_failassert_success)sample_schemac                     sT   G  fdddt j d jks$t ddddididd} tdd	gi| d
 d S )Nc                       s&   e Zd Z fddZdd Z  ZS )z=test_contextual_data_preservation.<locals>.InheritedValidatorc                    s(   d|kr|d | _ t | j|| d S )Nworking_dir)r   super__init__)selfargskwargs)InheritedValidator	__class__ R/opt/alt/python38/lib/python3.8/site-packages/cerberus/tests/test_customization.pyr      s    
zFtest_contextual_data_preservation.<locals>.InheritedValidator.__init__c                 S   s   | j r
dS d S )NTr   r	   valuer   r   r   _validate_type_test   s    zQtest_contextual_data_preservation.<locals>.InheritedValidator._validate_type_test)__name__
__module____qualname__r   r   __classcell__r   r   )r   r   r      s   r   testlisttype)r   schemaz/tmpr   foo)	validator)cerberus	ValidatortypesAssertionErrorr   )vr   r   r   !test_contextual_data_preservation
   s    
 r$   c                  C   s2   G dd dt j} d| jks td| jks.td S )Nc                   @   s   e Zd Zdd Zdd ZdS )z/test_docstring_parsing.<locals>.CustomValidatorc                 S   s   dS )z{'type': 'zap'}Nr   )r	   Zargumentfieldr   r   r   r   _validate_foo   s    z=test_docstring_parsing.<locals>.CustomValidator._validate_fooc                 S   s   dS )z
            Test the barreness of a value.

            The rule's arguments are validated against this schema:
                {'type': 'boolean'}
            Nr   r   r   r   r   _validate_bar"   s    z=test_docstring_parsing.<locals>.CustomValidator._validate_barN)r   r   r   r&   r'   r   r   r   r   CustomValidator   s   r(   r   Zbar)r   r    Zvalidation_rulesr"   )r(   r   r   r   test_docstring_parsing   s    r)   rule)Z
check_withr   c                 C   sX   G dd dt j}|d| diid}tddi|d tddi|dd	t jjd d
fd d S )Nc                   @   s   e Zd Zdd ZdS )z+test_check_with_method.<locals>.MyValidatorc                 S   s   |d@ s|  |d d S N   Must be an odd number_errorr	   r%   r   r   r   r   _check_with_oddity4   s    z>test_check_with_method.<locals>.MyValidator._check_with_oddityN)r   r   r   r1   r   r   r   r   MyValidator3   s   r2   amountoddityr   r,   documentr      r   r-   r7   r   errorr   r    r   r   errorsZCUSTOMr*   r2   r#   r   r   r   test_check_with_method0   s    r?   c                 C   sX   G dd dt j}|d| diid}tddi|d tddi|dd	t jjd d
fd d S )Nc                   @   s   e Zd Zdd ZdS )z*test_validator_method.<locals>.MyValidatorc                 S   s   |d@ s|  |d d S r+   r.   r0   r   r   r   _validator_oddityE   s    z<test_validator_method.<locals>.MyValidator._validator_oddityN)r   r   r   r@   r   r   r   r   r2   D   s   r2   r3   r4   r5   r,   r6   r8   r   r9   r:   r<   r>   r   r   r   test_validator_methodB   s    rA   c                  C   sH   G dd dt j} | td}|jddids0t|jddidrDtd S )Nc                   @   s"   e Zd ZdZejjjdd ZdS )zWtest_schema_validation_can_be_disabled_in_schema_setter.<locals>.NonvalidatingValidatorzD
        Skips schema validation to speed up initialization
        c                 S   sF   |d krd | _ n2| jr|| _ n$t|tjjr4|| _ ntj|| _ d S )N)Z_schemaZis_child
isinstancer   r   ZDefinitionSchemaZUnvalidatedSchema)r	   r   r   r   r   r   X   s    z^test_schema_validation_can_be_disabled_in_schema_setter.<locals>.NonvalidatingValidator.schemaN)r   r   r   __doc__r   r    r   setterr   r   r   r   NonvalidatingValidatorS   s   rE   r5   Z
an_integerr,   )r7   a)r   r    r   validater"   )rE   r#   r   r   r   7test_schema_validation_can_be_disabled_in_schema_setterR   s    
rH   )pytestr   r   Zcerberus.testsr   r   Zcerberus.tests.conftestr   r$   r)   Zparametrizer?   rA   rH   r   r   r   r   <module>   s   



