a
    e	g)                     @   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J |pd| |f dS )z.Assert a == b, with repr messaging on failure.z%r != %rN abmsgr   r   Z/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/mako/testing/assertions.pyeq_   s    r   c                 C   s    | |ksJ |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    | |v sJ |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    | |vsJ |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ur(| js(ds(J 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__)	exceptionr   r   r    _assert_proper_exception_context   s    
r   c                 C   s$   t | j|s J 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   	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   sB   t | |||}||i | W d    n1 s20    Y  |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 | y } zz||_d}|d urnt|}t||tjsnJ d||f |d urt|| |r|st	| t
t|d W Y d }~n
d }~0 0 ~|sJ dd S )Nr   FTz%r !~ %szutf-8z#Callable did not raise an exception)r+   sysexc_infor)   strresearchUNICODEr   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    r?   Tc                 C   s   t | |dS r9   r:   r;   r   r   r   !expect_raises_with_proper_context   s    r@   c                 C   s   t | ||dS r=   r:   r>   r   r   r   )expect_raises_message_with_proper_context   s    rA   )N)N)N)N)NFN)NFN)F)F)T)T)
contextlibr2   r/   r   r	   r
   r   r   r   r   r    r!   r$   r&   r'   r   r+   contextmanagerr(   r<   r?   r@   rA   r   r   r   r   <module>   s4   



   
#


 