U
    \g%i)                     @   s   d dl Z d dlZd dlZd*ddZd+ddZd,ddZd-dd	Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zd.ddZG dd dZe jd/dd Zd0d!d"Zd1d#d$Zd2d&d'Zd3d(d)ZdS )4    Nc                 C   s    | |kst |pd| |f dS )z.Assert a == b, with repr messaging on failure.z%r != %rNAssertionErrorabmsg r   V/var/www/html/api-medvista/venv/lib/python3.8/site-packages/mako/testing/assertions.pyeq_   s    r
   c                 C   s    | |kst |pd| |f dS )z.Assert a != b, with repr messaging on failure.z%r == %rNr   r   r   r   r	   ne_   s    r   c                 C   s    | |kst |pd| |f dS )z.Assert a in b, with repr messaging on failure.z%r not in %rNr   r   r   r   r	   in_   s    r   c                 C   s    | |kst |pd| |f dS )z2Assert a in not b, with repr messaging on failure.z%r is in %rNr   r   r   r   r	   not_in   s    r   c                 C   s,   | j | jk	r(| js(ds(td| | j f dS )G  assert that any exception we're catching does not have a __context__
    without a __cause__, and that __suppress_context__ is never set.

    Python 3 will report nested as exceptions as "during the handling of
    error X, error Y occurred". That's not what we want to do. We want
    these exceptions in a cause chain.

    FzZException %r was correctly raised but did not set a cause, within context %r as its cause.N)__context__	__cause____suppress_context__r   )	exceptionr   r   r	    _assert_proper_exception_context   s    
r   c                 C   s$   t | j|s td| | j|f dS )r   zcException %r was correctly raised but has cause %r, which does not have the expected cause type %r.N)
isinstancer   r   )r   	cause_clsr   r   r	   _assert_proper_cause_cls/   s
    	
r   c                 O   s   t | |||S N_assert_raises
except_cls	callable_argskwr   r   r	   assert_raises?   s    r   c                 O   s   t | |||ddS )NTcheck_contextr   r   r   r   r	   !assert_raises_with_proper_contextC   s    r"   c                 O   s   t | ||||dS )N)r   r   )r   r   r   r   r   r   r   r	   assert_raises_with_given_causeG   s    r#   c                 O   s   t | ||||dS )N)r   r   r   r   r   r   kwargsr   r   r	   assert_raises_messageM   s    r&   c                 O   s   t | ||||ddS )NTr   r!   r   r$   r   r   r	   )assert_raises_message_with_proper_contextQ   s         r(   c                 O   s   t | |||||dS )N)r   r   r   )r   r   r   r   r   r%   r   r   r	   &assert_raises_message_with_given_causeY   s         r)   Fc              	   C   s*   t | |||}||| W 5 Q R X |jS r   )_expect_raiseserror)r   r   r   r%   r   r!   r   ecr   r   r	   r   a   s    	r   c                   @   s   e Zd ZdZdS )_ErrorContainerN)__name__
__module____qualname__r+   r   r   r   r	   r-   o   s   r-   c           	   
   c   s   t  }|rt d }z|V  d}W n | k
r } zr||_d}|d k	rpt|}t||tjsptd||f |d k	rt	|| |r|st
| tt|d W 5 d }~X Y nX ~|stdd S )Nr   FTz%r !~ %szutf-8z#Callable did not raise an exception)r-   sysexc_infor+   strresearchUNICODEr   r   r   printencode)	r   r   r!   r   r,   Zare_we_already_in_a_tracebacksuccesserrZerror_as_stringr   r   r	   r*   s   s,    
$r*   c                 C   s   t | |dS Nr    r*   r   r!   r   r   r	   expect_raises   s    r>   c                 C   s   t | ||dS Nr'   r<   r   r   r!   r   r   r	   expect_raises_message   s    rA   Tc                 C   s   t | |dS r;   r<   r=   r   r   r	   !expect_raises_with_proper_context   s    rB   c                 C   s   t | ||dS r?   r<   r@   r   r   r	   )expect_raises_message_with_proper_context   s    rC   )N)N)N)N)NFN)NFN)F)F)T)T)
contextlibr4   r1   r
   r   r   r   r   r   r   r"   r#   r&   r(   r)   r   r-   contextmanagerr*   r>   rA   rB   rC   r   r   r   r	   <module>   s4   



   
#


 