
    +hL                    p   U d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z
 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d Zd Zd Zd Zd Z	 d#dZ G d d      Zej>                  	 d$d       Z d%dZ!	 d&dZ"d'dZ#i Z$de%d<   d Z&d Z'd  Z(d! Z)d" Z*y)(    )annotationsN)Any)Dict)exc)default)URL)_expect_warnings)eq_)is_)is_false)is_not_)is_true)ne_	decoratorc                ~    | j                   | j                  ur%| j                  sJ d| d| j                   d       yy)aH  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.

    z
Exception z> was correctly raised but did not set a cause, within context z as its cause.N)__context__	__cause____suppress_context__)	exceptions    M/var/www/html/venv/lib/python3.12/site-packages/alembic/testing/assertions.py _assert_proper_exception_contextr      sI     	Y%8%88..	
 )//1	
u / 	9    c                "    t        | |||d      S )NTcheck_context_assert_raises
except_cls	callable_argskws       r   assert_raisesr$   +   s    *irNNr   c                    t        | |||      S Nr   r   s       r   assert_raises_context_okr'   /   s    *ir::r   c                $    t        | ||||d      S )NT)msgr   r   r    r)   r!   r"   kwargss        r   assert_raises_messager,   3   s    ItVD r   c                "    t        | ||||      S )N)r)   r   r*   s        r    assert_raises_message_context_okr.   9   s     *iv3GGr   c                    t        | ||      5 } ||i | d d d        |j                  S # 1 sw Y   j                  S xY wr&   )_expect_raiseserror)r    r!   r"   r+   r)   r   ecs          r   r   r   ?   sA     

C	7 #24"6"#88O#88Os   	+?c                      e Zd ZU dZded<   y)_ErrorContainerNr   r1   )__name__
__module____qualname__r1   __annotations__ r   r   r4   r4   G   s    E3r   r4   c              #    K   t               }|rt        j                         d   }	 | d}|sJ d       y # | $ r}||_        d}|V|rt	        |      |k(  sFJ | d|        t        j                  |t	        |      t
        j                        sJ | d|        |rst        |       t        t	        |      j                  d             Y d }~d }~ww xY ww)Nr   FT != z !~ zutf-8z#Callable did not raise an exception)r4   sysexc_infor1   strresearchUNICODEr   printencode)r    r)   r   
text_exactr2   are_we_already_in_a_tracebacksuccesserrs           r   r0   r0   K   s      
	B(+q(9%( 9997  
(?3x393%tC5(99yyc#h

;NuD=NN;!>,S1c#hoog&''
(s+   $C7 
CCBCCCCc                    t        | |      S )Nr   r0   )r    r   s     r   expect_raisesrJ   e   s    *MBBr   c                     t        | |||      S )N)r)   r   rD   rI   )r    r)   r   rD   s       r   expect_raises_messagerL   i   s     =Z r   c                    t        j                  dd|       } t        j                  dd|       } t        j                  dd|      }t        j                  dd|      }| |k(  sJ |xs | d|       y )Nz^\s+?|\n z {2,} r;   )r?   sub)abr)   s      r   eq_ignore_whitespacerS   q   se    
{B"A
xa A
{B"A
xa A6-3-1--6r   zDict[Any, Any]_dialect_modsc                    | | dk(  rt        j                         S  t        j                  |       j	                                }| dk(  r	d|_        |S | dk(  rd|_        |S )Nr   
postgresqlTmssqlF)r   DefaultDialectr   createget_dialectimplicit_returninglegacy_schema_aliasing)nameds     r   _get_dialectr_   }   sf    |ty(%%''*CJJt((*,<#'A   W_',A$r   c                 $    t        t        | fi |S )a  Context manager which expects one or more warnings.

    With no arguments, squelches all SAWarnings emitted via
    sqlalchemy.util.warn and sqlalchemy.util.warn_limited.   Otherwise
    pass string expressions that will match selected warnings via regex;
    all non-matching warnings are sent through.

    The expect version **asserts** that the warnings were in fact seen.

    Note that the test suite sets SAWarning warnings to raise exceptions.

    )r	   Warningmessagesr#   s     r   expect_warningsrd      s     GX444r   c                 $     t          fd       }|S )zDecorator form of expect_warnings().

    Note that emits_warning does **not** assert that the warnings
    were in fact seen.

    c                f    t        t        gddi5   | |i |cd d d        S # 1 sw Y   y xY w)Nassert_F)r	   DeprecationWarning)fnr"   r#   rc   s      r   decoratez2emits_python_deprecation_warning.<locals>.decorate   s6    0K(K%K 	#t?r?	# 	# 	#s   '0r   )rc   rj   s   ` r    emits_python_deprecation_warningrk      s     # # Or   c                 8    t        t        j                  | fi |S r&   )r	   sa_excSADeprecationWarningrb   s     r   expect_sqlalchemy_deprecatedro      s    F77HRHHr   c                 8    t        t        j                  | fi |S r&   )r	   rm   RemovedIn20Warningrb   s     r   expect_sqlalchemy_deprecated_20rr      s    F55xF2FFr   )NF)NFF)T)TFr&   )+
__future__r   
contextlibr?   r<   typingr   r   
sqlalchemyr   rm   sqlalchemy.enginer   r   sqlalchemy.testing.assertionsr	   r
   r   r   r   r   r   sqlalchemy.utilr   r   r$   r'   r,   r.   r   r4   contextmanagerr0   rJ   rL   rS   rT   r8   r_   rd   rk   ro   rr   r9   r   r   <module>r{      s    "  	 
   $ % ! : - - 2 1 1 - %
*O;H BG  :?: :2C
 5:. !#~ "
5  IGr   