
    gW                    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)_expect_warnings)eq_)is_)is_false)is_not_)is_true)ne_	decorator   )sqla_compatc                ~    | 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    Y/var/www/html/AdoubleTech/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(   0   s    *ir::r   c                $    t        | ||||d      S )NT)msgr   r   r!   r*   r"   r#   kwargss        r   assert_raises_messager-   4   s    ItVD r   c                "    t        | ||||      S )N)r*   r   r+   s        r    assert_raises_message_context_okr/   :   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   r2   )__name__
__module____qualname__r2   __annotations__ r   r   r5   r5   H   s    E3r   r5   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)r5   sysexc_infor2   strresearchUNICODEr   printencode)r!   r*   r   
text_exactr3   are_we_already_in_a_tracebacksuccesserrs           r   r1   r1   L   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   r1   )r!   r   s     r   expect_raisesrK   f   s    *MBBr   c                     t        | |||      S )N)r*   r   rE   rJ   )r!   r*   r   rE   s       r   expect_raises_messagerM   j   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_whitespacerT   r   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_urlget_dialectimplicit_returninglegacy_schema_aliasing)nameds     r   _get_dialectr`   ~   sh    |ty(%%''7K##D)5579<#'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_warningsre      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$   rd   s      r   decoratez2emits_python_deprecation_warning.<locals>.decorate   s6    0K(K%K 	#t?r?	# 	# 	#s   '0r   )rd   rk   s   ` r    emits_python_deprecation_warningrl      s     # # Or   c                 8    t        t        j                  | fi |S r'   )r   sa_excSADeprecationWarningrc   s     r   expect_sqlalchemy_deprecatedrp      s    F77HRHHr   c                 8    t        t        j                  | fi |S r'   )r   rn   RemovedIn20Warningrc   s     r   expect_sqlalchemy_deprecated_20rs      s    F55xF2FFr   )NF)NFF)T)TFr'   ),
__future__r   
contextlibr@   r=   typingr   r   
sqlalchemyr   rn   sqlalchemy.enginer   sqlalchemy.testing.assertionsr   r	   r
   r   r   r   r   sqlalchemy.utilr   utilr   r   r%   r(   r-   r/   r   r5   contextmanagerr1   rK   rM   rT   rU   r9   r`   re   rl   rp   rs   r:   r   r   <module>r}      s    "  	 
   $ % : - - 2 1 1 - % 
*O;H BG  :?: :2C
 5:. !#~ "
5  IGr   