
    h                    l   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    e/var/www/html/retail-simulation-api/retail/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_okr0   :   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   @   s<     

C	724"6" 
888O 
888Os   	+?c                      e Zd ZU dZded<   y)_ErrorContainerNr   r3   )__name__
__module____qualname__r3   __annotations__ r   r   r6   r6   H   s    E3r   r6   c              #    K   t               }|rt        j                         d   }	 | d}|sJ d       y # | $ r}||_        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   FTz !~ zutf-8z#Callable did not raise an exception)r6   sysexc_infor3   researchstrUNICODEr   printencode)r!   r+   r   r4   are_we_already_in_a_tracebacksuccesserrs          r   r2   r2   L   s     		B(+q(9%
( 9997  (?99S#c(BJJ7JC5SE9JJ7!>,S1c#hoog&''(s+   $C 7 
C B=A7B83C 8B==C c                    t        | |      S )Nr   r2   )r!   r   s     r   expect_raisesrJ   a   s    *MBBr   c                    t        | ||      S )Nr*   rI   )r!   r+   r   s      r   expect_raises_messagerL   e   s    *#]KKr   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,} z != )r?   sub)abr+   s      r   eq_ignore_whitespacerS   i   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_   u   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_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   s2    0K(K%Kt?r?	# 	#KKs   '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)Tr'   ),
__future__r   
contextlibr?   r=   typingr   r   
sqlalchemyr   rm   sqlalchemy.enginer   sqlalchemy.testing.assertionsr   r	   r
   r   r   r   r   sqlalchemy.utilr   utilr   r   r%   r(   r.   r0   r   r6   contextmanagerr2   rJ   rL   rS   rT   r:   r_   rd   rk   ro   rr   r;   r   r   <module>r|      s    "  	 
   $ % : - - 2 1 1 - % 
*O;H BG  : :(CL. !#~ "
5  IGr   