File: //opt/alt/python38/lib/python3.8/site-packages/cerberus/tests/__pycache__/__init__.cpython-38.pyc
U
���`O � @ s� d dl Z d dlZd dlmZmZmZmZ d dlmZ i dddfdd�Z dd� Z
dd � Zddd�Zdd
d�Z
ddd�Zdd� Zdd� Zdd� Zddd�ZdS )� N)�errors� Validator�SchemaError�
DocumentError)�
sample_schemac C sf |dkrt � }|dkr8t�| �� |||� W 5 Q R X n*tj| t�|�d�� |||� W 5 Q R X dS )z
Tests whether a specific exception is raised. Optionally also tests whether the
exception message is as expected.
N)�match)r �pytestZraises�re�escape)� exception�document�schema� validator�msg� r �H/opt/alt/python38/lib/python3.8/site-packages/cerberus/tests/__init__.py�assert_exception s r c G s t tf| �� dS )zITests whether a validation raises an exception due to a malformed schema.N)r r ��argsr r r �assert_schema_error s r c G s t tf| �� dS )zKTests whether a validation raises an exception due to a malformed document.N)r r r r r r �assert_document_error s r Fc C s� |dkrt t�}|| ||�}t|t�s*t�|r2t�|j}|dk rL|dk rLt�|dk rd|dk rdtd��|dk rx|dkrxt�|dk r�t|�dks�t�t|f|�� |dk r�t|d j�t|�ks�t�t |d j|� n&|dk r�t|�t|�ks�t�t ||� |S )z!Tests whether a validation fails.NzGchild_errors can only be tested in conjunction with the error parameter� r )
r r �
isinstance�bool�AssertionError�_errors�len�assert_has_error�child_errors�assert_has_errors) r r
r �update�errorr r �resultZ
actual_errorsr r r �assert_fail$ s*
�
r# c C s<