File manager - Edit - /opt/alt/python38/lib/python3.8/site-packages/cerberus/tests/__pycache__/__init__.cpython-38.opt-1.pyc
Back
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)Z 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 sh |dkrt t�}|| ||�}|j}|dk rRt|f|�� |dk rdt|d j|� n|dk rdt||� |S )z!Tests whether a validation fails.Nr )r r �_errors�assert_has_error�assert_has_errors�child_errors) r r r �update�errorr r �resultZ actual_errorsr r r �assert_fail$ s r c C s. |dkrt t�}|| ||�}|s*t|j��dS )z$Tests whether a validation succeeds.N)r r �AssertionErrorr )r r r r r r r r �assert_successJ s r r c C s� t |t�s|f}t |t�s |f}t| �D ]@\}}z |js8W n( tk rN Y q( tk rb � Y q(X q�q(tdj||t|j�||| 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_pathZschema_path�code�info� constraintr ) � isinstance�tuple� enumerateZis_group_errorr � Exception�format�hexr )r Zd_pathZs_pathZ error_defr"