
    i                    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+dS ))    )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            dS dS )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.

    Fz
Exception z> was correctly raised but did not set a cause, within context z as its cause.N)__context__	__cause____suppress_context__)	exceptions    `/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/alembic/testing/assertions.py _assert_proper_exception_contextr      s]     	Y%888. 	9	
 	
 yy)///1	
 	
u 	9888    c                *    t          | |||d          S )NTcheck_context_assert_raises
except_cls	callable_argskws       r   assert_raisesr%   ,   s    *irNN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GGGr   Fc                r    t          | ||          5 } ||i | d d d            n# 1 swxY w Y   |j        S r'   )_expect_raiseserror)r!   r"   r#   r-   r+   r   ecs          r   r   r   @   s     

C	7	7 #2	4"6"""# # # # # # # # # # # # # # #8Os   	'++c                      e Zd ZU dZded<   dS )_ErrorContainerNr   r3   )__name__
__module____qualname__r3   __annotations__ r   r   r6   r6   H   s#         Er   r6   c              #    K   t                      }|rt          j                    d         }	 |V  d}n# | $ r}||_        d}|<t	          j        |t          |          t          j                  sJ | d|             |r|st          |           t          t          |          
                    d                     Y d }~nd }~ww xY w|s
J d            d S )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%
( ( ( (?9S#c((BJ77JJC9J9JS9J9JJJ7 	2!> 	2,S111c#hhoog&&''''''''( 99999799s   4 CB	CCTc                $    t          | |          S )Nr   r2   )r!   r   s     r   expect_raisesrJ   a   s    *MBBBBr   c                &    t          | ||          S )Nr*   rI   )r!   r+   r   s      r   expect_raises_messagerL   e   s    *#]KKKKr   c                    t          j        dd|           } t          j        dd|           } t          j        dd|          }t          j        dd|          }| |k    sJ |p| d|            d S )Nz^\s+?|\n z {2,} z != )r?   sub)abr+   s      r   eq_ignore_whitespacerS   i   su    
{B""A
xa  A
{B""A
xa  A6663-11-66666r   zDict[Any, Any]_dialect_modsc                    | | dk    rt          j                    S  t          j        |                                                       }| dk    rd|_        n| 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   sp    |ty((%'''7K#D))55779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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                r    t          t          gR ddi5   | |i |cd d d            S # 1 swxY w Y   d S )Nassert_F)r   DeprecationWarning)fnr#   r$   rc   s      r   decoratez2emits_python_deprecation_warning.<locals>.decorate   s    0K(KKK%KK 	# 	#2t?r??	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   ,00r   )rc   rj   s   ` r    emits_python_deprecation_warningrk      s/     # # # # Y# Or   c                 2    t          t          j        | fi |S r'   )r   sa_excSADeprecationWarningrb   s     r   expect_sqlalchemy_deprecatedro      s    F7HHRHHHr   c                 2    t          t          j        | fi |S r'   )r   rm   RemovedIn20Warningrb   s     r   expect_sqlalchemy_deprecated_20rr      s    F5xFF2F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 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 - - - - - - % % % % % %      
 
 
*O O O; ; ;  H H H BG           : : : :(C C C CL L L L. . . . !# " " " "
 
 
5 5 5    I I IG G G G Gr   