B
    d*                 @   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   d/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/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 == %rN)r   )r   r   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 %rN)r   )r   r   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 %rN)r   )r   r   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 )aG  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 )aG  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.

    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_context)r   )r   r   r   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   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 d Q R X |jS )N)_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$   p   s   r$   c       	   
   c   s   t  }|rt d }y|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 d 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!   t   s*    

$r!   c             C   s   t | |dS )N)r   )r!   )r   r   r   r   r   expect_raises   s    r2   c             C   s   t | ||dS )N)r   r   )r!   )r   r   r   r   r   r   expect_raises_message   s    r3   Tc             C   s   t | |dS )N)r   )r!   )r   r   r   r   r   !expect_raises_with_proper_context   s    r4   c             C   s   t | ||dS )N)r   r   )r!   )r   r   r   r   r   r   )expect_raises_message_with_proper_context   s    r5   )N)N)N)N)NFN)NFN)F)F)T)T)
contextlibr+   r(   r   r	   r
   r   r   r   r   r   r   r   r   r    r   r$   contextmanagerr!   r2   r3   r4   r5   r   r   r   r   <module>   s0   



  
#


