o
    h)                     @   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d,d!d"Zd,d#d$Zd-d&d'Z	%d-d(d)ZdS ).    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   k/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/mako/testing/assertions.pyeq_       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_   r	   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_   r	   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   r	   r   c                 C   s,   | j | jur| jsJ d| | j f dS 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?      r   c                 O   s   t | |||ddS )NTcheck_contextr   r   r   r   r   !assert_raises_with_proper_contextC      r"   c                 O      t | ||||dS )N)r   r   )r   r   r   r   r   r   r   r   assert_raises_with_given_causeG   s   r%   c                 O   r$   )N)r   r   r   r   r   r   kwargsr   r   r   assert_raises_messageM   r#   r(   c                 O   s   t | ||||ddS )NTr   r!   r   r&   r   r   r   )assert_raises_message_with_proper_contextQ      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   r+   r,   Fc                 C   sF   t | |||}||i | W d    |jS 1 sw   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   r0   o   s    r0   c           	   
   c   s    t  }|rt d }z|V  d}W nI | y\ } z=||_d}|d ur8t|}t||tjs8J d||f |d urAt|| |rI|sIt	| t
t|d W Y d }~nd }~ww ~|sdJ dd S )Nr   FTz%r !~ %szutf-8z#Callable did not raise an exception)r0   sysexc_infor.   strresearchUNICODEr   r   printencode)	r   r   r!   r   r/   are_we_already_in_a_tracebacksuccesserrerror_as_stringr   r   r   r-   s   s2   
r-   c                 C      t | |dS Nr    r-   r   r!   r   r   r   expect_raises      rD   c                 C      t | ||dS Nr)   rB   r   r   r!   r   r   r   expect_raises_message   r   rI   Tc                 C   r@   rA   rB   rC   r   r   r   !expect_raises_with_proper_context   rE   rJ   c                 C   rF   rG   rB   rH   r   r   r   )expect_raises_message_with_proper_context   s   rK   r   )NFN)F)T)
contextlibr7   r4   r   r
   r   r   r   r   r   r"   r%   r(   r*   r,   r   r0   contextmanagerr-   rD   rI   rJ   rK   r   r   r   r   <module>   s6    





#

