o
    gz                     @  s  d dl mZ d dlmZ d dlZd dlmZ 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dlmZ ddlmZ dd Z ej!dd Z"dd Z#dd Z$dd  Z%d!d" Z&d#d$ Z'da(da)da*	%	&	%dod'd(Z+ej!	%	&	%	&	&dpd)d*Z,d+d, Z-d-d. Z.d/d0 Z/dqd1d2Z0dqd3d4Z1dqd5d6Z2dqd7d8Z3dqd9d:Z4dqd;d<Z5dqd=d>Z6dqd?d@Z7dqdAdBZ8dqdCdDZ9dqdEdFZ:e:Z;dqdGdHZ<dqdIdJZ=e=Z>dqdKdLZ?dqdMdNZ@dOdP ZAdQdR ZBdSdT ZCdUdV ZDdWdX ZEdYdZ ZFd[d\ ZG	&drd]d^ZHG d_d` d`ZIej!drdadbZJdsdcddZKdsdedfZLG dgdh dhZMG didj djZNG dkdl dlZOG dmdn dnZPdS )t    )annotations)defaultdictN)copy)filterfalse   )	assertsql)config)engines)mock)db_spec)fail   )exc)schema)sql)types)util)default)url)LABEL_STYLE_TABLENAME_PLUS_COL	decoratorc                  O     t tj| fi |S )a  Context manager which expects one or more warnings.

    With no arguments, squelches all SAWarning 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.

    )_expect_warnings_sqla_onlysa_exc	SAWarningmessageskw r   _/var/www/html/ecg_monitoring/venv/lib/python3.10/site-packages/sqlalchemy/testing/assertions.pyexpect_warnings%   s   r!   c                 o  sb    t | }t| tr|tjsdV  dS t|i | dV  W d   dS 1 s*w   Y  dS )zContext manager which expects one or more warnings on specific
    dialects.

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

    N)r   
isinstancestrr   _currentr!   )dbr   r   specr   r   r    expect_warnings_on5   s   
"r'   c                       t  fdd}|S )zDecorator form of expect_warnings().

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

    c                   @   t  ddi | |i |W  d    S 1 sw   Y  d S Nassert_F)r!   fnargsr   r   r   r    decorateN      $zemits_warning.<locals>.decorater   r   r0   r   r/   r    emits_warningF   s   r3   c                  O  r   N)r   r   SADeprecationWarningr   r   r   r    expect_deprecatedV   
   r6   c                  O  r   r4   )r   r   Base20DeprecationWarningr   r   r   r    expect_deprecated_20\   r7   r9   c                   s   t  fdd}|S )aV  Mark a test as emitting a warning on a specific dialect.

    With no arguments, squelches all SAWarning failures.  Or pass one or more
    strings; these will be matched to the root of the warning description by
    warnings.filterwarnings().

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

    c                   sH   t  gR ddi | |i |W  d    S 1 sw   Y  d S r*   )r'   r,   r%   r   r   r    r0   n   s   $z"emits_warning_on.<locals>.decorater   )r%   r   r0   r   r:   r    emits_warning_onb   s   r;   c                    r(   )a+  Mark a test as immune from fatal deprecation warnings.

    With no arguments, squelches all SADeprecationWarning failures.
    Or pass one or more strings; these will be matched to the root
    of the warning description by warnings.filterwarnings().

    As a special case, you may pass a function name prefixed with //
    and it will be re-written as needed to match the standard warning
    verbiage emitted by the sqlalchemy.util.deprecated decorator.

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

    c                   r)   r*   )r6   r,   r/   r   r    r0      r1   z!uses_deprecated.<locals>.decorater   r2   r   r/   r    uses_deprecatedv   s   r<   TFc                 C  s   t | ||||ddS )zSQLAlchemy internal use only _expect_warnings().

    Alembic is using _expect_warnings() directly, and should be updated
    to use this new interface.

    T)regex
search_msgr+   raise_on_any_unexpected)_expect_warnings)exc_clsr   r=   r>   r+   r   r   r    r      s   r   c                 #  sT   srdd |D  nt | td ur5td usJ td us!J t  t  t| f7 ad V  d S t  a a| farGdd ntj fdd}t	
d|D zd V  W d  a aa|r|r|J dd	fd
dD  nd  a aa|rrJ dd	fd
dD  w W d    d S 1 sw   Y  d S )Nc                 S  s    g | ]}t |t jt jB qS r   )recompileIS).0msgr   r   r    
<listcomp>   s     z$_expect_warnings.<locals>.<listcomp>c                 _  s   t d|  )NzGot unexpected warning: %r)AssertionError)rG   argr   r   r   r    	real_warn      z#_expect_warnings.<locals>.real_warnc                   s   t | trt| }t| } n	|r|d }nd }|rt|ts-s+| g|R i |S d S  s3s3d S  D ]}r>|| sKrE|| sKsS|| krS|  d S q5sc| g|R i | d S d S )Nr   )r"   _EXC_CLStyper#   
issubclasssearchmatchdiscard)rG   rJ   r   	exceptionfilter_filtersr?   rK   r=   r>   seensquelch_other_warningsr   r    our_warn   s<   



z"_expect_warnings.<locals>.our_warnzwarnings.warnzWarnings were not seen: %sz, c                 3  s"    | ]}d  r
|j n| V  qdS )z%rN)pattern)rF   s)r=   r   r    	<genexpr>   s    
z#_expect_warnings.<locals>.<genexpr>)list_FILTERS_SEENrM   extendupdatesetwarningswarnr
   patchjoin)rA   r   r=   r>   r+   r?   rX   rY   r   rU   r    r@      sD   




"r@   c                   C  s
   t   dS )zCheck things that have to be finalized at the end of a test suite.

    Hardcoded at the moment, a modular system can be built here
    to support things like PG prepared transactions, tables all
    dropped, etc.

    N)!_assert_no_stray_pool_connectionsr   r   r   r    global_cleanup_assertions   s   
rh   c                   C  s   t j  d S r4   )r	   testing_reaperassert_all_closedr   r   r   r    rg        rg   c                 C  s6   t | | }t||  |k sJ d||d | f d S )Nz:Given int value %s is not within %d%% of expected value %sd   )intabs)expectedreceivedvariancedeviancer   r   r    int_within_variance
  s   rs   c                 C  s$   t || sJ |pd| |f d S )Nz%r !~ %r)rB   rQ   abrG   r   r   r    eq_regex  s   $rw   c                 C  s    | |ksJ |pd| |f dS )z.Assert a == b, with repr messaging on failure.%r != %rNr   rt   r   r   r    eq_      ry   c                 C  s    | |ksJ |pd| |f dS )z.Assert a != b, with repr messaging on failure.z%r == %rNr   rt   r   r   r    ne_  rz   r{   c                 C  s    | |ksJ |pd| |f dS )z.Assert a <= b, with repr messaging on failure.rx   Nr   rt   r   r   r    le_#  rz   r|   c                 C  s"   t | |sJ |pd| |f d S )Nz%r is not an instance of %rr"   rt   r   r   r    is_instance_of(  s   "r~   c                 C     t | d |d d S NrG   )is_ru   rG   r   r   r    is_none,     r   c                 C  r   r   )is_notr   r   r   r    is_not_none0  r   r   c                 C     t t| d|d d S )NTr   r   boolr   r   r   r    is_true4     r   c                 C  r   )NFr   r   r   r   r   r    is_false8  r   r   c                 C  s    | |u sJ |pd| |f dS )z.Assert a is b, with repr messaging on failure.z%r is not %rNr   rt   r   r   r    r   <  rz   r   c                 C  s    | |usJ |pd| |f dS )z2Assert a is not b, with repr messaging on failure.z%r is %rNr   rt   r   r   r    r   A  rz   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   rt   r   r   r    in_J  rz   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   rt   r   r   r    not_inO  rz   r   c                 C  s"   |  |sJ |pd| |f dS )z>Assert a.startswith(fragment), with repr messaging on failure.z%r does not start with %rN)
startswith)ru   fragmentrG   r   r   r    startswith_X  s   r   c                 C  st   t dd| } t dd| } t dd| } t dd|}t dd|}t dd|}| |ks8J |p6d| |f d S )Nz^\s+?|\n z {2,} z\trx   )rB   subrt   r   r   r    eq_ignore_whitespace`  s    r   c                 C  s,   | j | jur| jsJ d| | j f 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.

    FzZException %r was correctly raised but did not set a cause, within context %r as its cause.N)__context__	__cause____suppress_context__)rS   r   r   r     _assert_proper_exception_contextk  s   r   c                 O  s   t | |||ddS )NTcheck_context_assert_raises
except_cls	callable_r.   r   r   r   r    assert_raises  r   r   c                 O  s   t | |||S r4   r   r   r   r   r    assert_raises_context_ok  rk   r   c                 O  s   t | ||||ddS )NTrG   r   r   r   rG   r   r.   kwargsr   r   r    assert_raises_message  s   r   c                 O  s>   t | dg ||i |W  d   S 1 sw   Y  dS )a  legacy adapter function for functions that were previously using
    assert_raises with SAWarning or similar.

    has some workarounds to accommodate the fact that the callable completes
    with this approach rather than stopping at the exception raise.


    z.*Nr   )r   r   r.   r   r   r   r    assert_warns  s   	$r   c                 O  sD   t | |gddd ||i |W  d   S 1 sw   Y  dS )aq  legacy adapter function for functions that were previously using
    assert_raises with SAWarning or similar.

    has some workarounds to accommodate the fact that the callable completes
    with this approach rather than stopping at the exception raise.

    Also uses regex.search() to match the given message to the error string
    rather than regex.match().

    TF)r>   r=   Nr   r   r   r   r    assert_warns_message  s   $r   c                 O  s   t | ||||dS r   r   r   r   r   r     assert_raises_message_context_ok  s   r   c                 C  sD   t | ||}||i | W d    |jS 1 sw   Y  |jS r4   )_expect_raiseserror)r   r   r.   r   rG   r   ecr   r   r    r     s   
r   c                   @  s   e Zd ZdZdS )_ErrorContainerN)__name__
__module____qualname__r   r   r   r   r    r     s    r   c              
   c  s    t | trt| tst | trtdt }|rt d }z|V  d}W n@ | yf } z4||_d}|d urKt	|}t
||t
jsKJ d||f |rS|sSt| tt	|d W Y d }~nd }~ww ~|snJ dd S )NzCUse expect_warnings for warnings, not expect_raises / assert_raisesr   FTz%r !~ %sutf-8z#Callable did not raise an exception)r"   rN   rO   Warning	TypeErrorr   sysexc_infor   r#   rB   rP   UNICODEr   printencode)r   rG   r   r   are_we_already_in_a_tracebacksuccesserrerror_as_stringr   r   r    r     s@   r   c                 C  s   t | |dS )Nr   r   )r   r   r   r   r    expect_raises  rL   r   c                 C  s   t | ||dS )Nr   r   )r   rG   r   r   r   r    expect_raises_message  rk   r   c                   @  s>   e Zd Z																				dddZdS )AssertsCompiledSQLNFTc           /   	     s  |rt  |_|_nL|rd nGd u rt| dd d u r%tjjn4dks-dkrBdkr6t  nt d|_|_ndkrKt  nt	t
rYtj  |r^|_i }i }|rh||d< |d urrt||d< |rxd|d	< |r~d|d
< |rd|d< |rd|d< |rd|d< |st| ddrtj|d< ddlm} t	||jr| }t|_|}|r||d< G dd d G  fddd}||jd5di|t	|tjr|j}|rt| n| }|rt|d  ttdi }| d!dd}t"dt
 |  d t#$ddt
}t%||d ||f  |d ur@|r8j&|dd!t%j'| nt%(|| |	d uru|r_j&|dd!t%t)fd"d#j*D |	 nj(|dd!t%t)fd$d#j*D |	 |
d urt%j+|
 |d urt%fd%d&j,D | |d urt%fd'd&j-D | |rutdd rwfd(d)}|d*d} |jd5d| i|}!t#$ddt
|!}|dd}"|jd5d|"i|}#t|#j*}$|#j.}%|#j-|#j,B D ]}&|#j/|& |$v rfd+d#|$D }$qg t0t}'|$D ]B}(z.|(|'v r|'|( d, })nd})|%1|(|(}*|2d-|*f |)d. }+3|+ |'|( 3|+ W q t4yJ   d/|(|f },J |,w t5fd0d1t6d2t7D }-d3d# t8t9|$D }.d4|$|.|f },t:|-|, d S d S d S )6N__dialect__r   default_qmarkqmarkdefault_enhancedschema_translate_mapcolumn_keysTliteral_bindsrender_postcompile"use_literal_execute_for_simple_intfor_executemanyrender_schema_translateassert_from_lintingFlintingr   )ormcompile_kwargsc                   @     e Zd Zdd ZdS )z5AssertsCompiledSQL.assert_compile.<locals>.DontAccessc                 S  s   t d)Nz=compiler accessed .statement; use compiler.current_executable)NotImplementedError)selfkeyr   r   r    __getattribute__O  s   zFAssertsCompiledSQL.assert_compile.<locals>.DontAccess.__getattribute__N)r   r   r   r   r   r   r   r    
DontAccessN      r   c                      sD   e Zd Zdd Zedd Zdd Zdd Zd	d
 Z fddZ	dS )z>AssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccessc                 S  sj   || _ i | _t|dd| _| jr1|j| _t|dr|j| _t|dr&|j| _t|dr3|j| _d S d S d S )Nsupports_executionF
_returning_inline_return_defaults)	test_statement_annotationsgetattrr   _execution_optionshasattrr   r   r   )r   r   r   r   r    __init__V  s   


zGAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess.__init__c                 S  s   | j jS r4   )r   _variant_mappingr   r   r   r    r   g  s   zOAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess._variant_mappingc                 S  s
   | j  S r4   )r   _default_dialectr   r   r   r    r   k  s   
zOAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess._default_dialectc                 [  s   | j jj| fd|i|S )Ndialect)r   rC   __func__r   r   r   r   r   r    rC   n  s   zFAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess.compilec                 [  s   | j jj| |fi |S r4   )r   	_compilerr   r   r   r   r    r   s  s
   zHAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess._compilerc                   sh   t |dr*tj|d   | jj|fi |W  d    S 1 s#w   Y  d S | jj|fi |S )N	statement)r   r
   re   objectr   _compiler_dispatch)r   compilerr   r   r   r    r   x  s   
$zQAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess._compiler_dispatchN)
r   r   r   r   propertyr   r   rC   r   r   r   r   r   r    CheckCompilerAccessU  s    
r   r   paramsr   asciiignorez
SQL String:
z[\n\t]r   z%r != %r on dialect %r)escape_namesc                   s   g | ]} j | qS r   )
parametersrF   x)expanded_stater   r    rH     s    z5AssertsCompiledSQL.assert_compile.<locals>.<listcomp>c                   s   g | ]} | qS r   r   r   )pr   r    rH         c                      i | ]	} j | |jqS r   
bind_nameseffective_valuerF   rv   cr   r    
<dictcomp>      z5AssertsCompiledSQL.assert_compile.<locals>.<dictcomp>c                   r   r   r   r   r   r   r    r    r  c                   s   t  }| |_||_|S r4   )r   
paramstyle
positional)r  r  cp)r   r   r    get_dialect  s   z6AssertsCompiledSQL.assert_compile.<locals>.get_dialectpyformatc                   s   g | ]}| kr|qS r   r   )rF   vnamer   r    rH         z%%(%s)sr   z#Expected to find bindparam %r in %rc                 3  s$    | ]} |d    | k V  qdS )r   Nr   )rF   i)	positionsr   r    r\     s
    
z4AssertsCompiledSQL.assert_compile.<locals>.<genexpr>r   c                 S  s   g | ]\}}|qS r   r   )rF   _r	  r   r   r    rH     r   zQOrder of parameters %s does not match the order in the statement %s. Statement %rr   );r   DefaultDialectsupports_default_valuessupports_default_metavaluer   r   r%   r   StrCompileDialectr"   r#   r   URLcreater  default_schema_namer]   r   FROM_LINTING
sqlalchemyr   Query_statement_20r   _label_stylerC   sqltypes
TypeEngine_static_cache_keyhash_generate_cache_keyreprr   decoder   rB   r   ry   construct_expanded_stater   construct_paramstuplepositiontupprefetchliteral_execute_paramspost_compile_paramsescaped_bind_namesr   r   getindexappend
ValueErrorallrangelensortedzipr   )/r   clauseresultr   checkparamsr   check_literal_executecheck_post_paramr   checkpositionalcheck_prefetchuse_default_dialectallow_dialect_selectr  r  r   r   r   r   r  from_lintingcheck_param_orderr   r   r   r   stmtr   cache_key_no_warnings	param_strccr  pyformat_dialect
pyformat_cqmark_dialectqmark_cvaluesescaped
post_parampos_by_valuer	  startescposrG   orderedro   r   )r   r  r   r   r  r   r  r    assert_compile  s  





3
















z!AssertsCompiledSQL.assert_compile)NNFNNNNNFFTTFFNFNFTF)r   r   r   rP  r   r   r   r    r     s,    r   c                   @  s"   e Zd Z		dddZdd ZdS )	ComparesTablesFTc                 C  sR  t |jt |jksJ t|j|jD ]r\}}t|j|j ||j|j u s(J |r8t|j|j t|j|j |rPd}t|jt|jsOJ ||j|jf n| 	|| t|jt
jrft|jj|jj |rytdd |jD dd |jD  |jrt|jtjsJ q|rt |jt |jksJ |jD ]}|jj|j d usJ qd S d S )Nz)Type '%s' doesn't correspond to type '%s'c                 S     h | ]}|j jqS r   columnr  rF   fr   r   r    	<setcomp>  r   z5ComparesTables.assert_tables_equal.<locals>.<setcomp>c                 S  rR  r   rS  rU  r   r   r    rW    r   )r2  r  r4  ry   r  primary_keynullabler"   rN   assert_types_baser  Stringlengthforeign_keysserver_defaultr   FetchedValuecolumns)r   tablereflected_tablestrict_typesstrict_constraintsr  reflected_crG   r   r   r    assert_tables_equal  s@   

z"ComparesTables.assert_tables_equalc                 C  s*   |j |j sJ d|j|j |j f d S )Nz7On column %r, type '%s' doesn't correspond to type '%s')rN   _compare_type_affinityr  )r   c1c2r   r   r    rZ  (  s   z ComparesTables.assert_types_baseN)FT)r   r   r   rf  rZ  r   r   r   r    rQ    s
    
+rQ  c                   @  sr   e Zd Zdd Zdd Zdd Zdd Zdd
dZdd Zdd Z	dd Z
ejdd Zdd Zejdd Zd	S )AssertsExecutionResultsc                 G  s&   t |}tt| | ||| d S r4   )r]   r   r"  assert_list)r   r6  class_objectsr   r   r    assert_result3  s   z%AssertsExecutionResults.assert_resultc                 C  sL   |  t|t|kd|j  tdt|D ]}| ||| ||  qd S )Nz9result list is not the same size as test list, for class r   )r+   r2  r   r1  
assert_row)r   r6  rl  list_r  r   r   r    rk  8  s   z#AssertsExecutionResults.assert_listc              	   C  s   |  |j|u dt|  | D ]A\}}t|tr?t|d tr0| t|||d |d  q| 	|d t|||d  q|  t|||kd|t|||f  qd S )Nzitem class is not r   r   z'attribute %s value %s does not match %s)
r+   	__class__r"  itemsr"   r&  r]   rk  r   ro  )r   rl  rowobjdescr   valuer   r   r    ro  B  s   
z"AssertsExecutionResults.assert_rowc           	        s   G dd dt t|}fdd|D }tfdd|D ]}tdt|jjf  qt|t|krBtdt|t|f  t   fd	d
}|D ]}|D ]}|||r`|	|  nqRtdjt
|f  qNdS )zAs assert_result, but the order of objects is not considered.

        The algorithm is very expensive but not a big deal for the small
        numbers of rows that the test suite manipulates.
        c                   @  r   )zFAssertsExecutionResults.assert_unordered_result.<locals>.immutabledictc                 S  s   t | S r4   )idr   r   r   r    __hash__[  s   zOAssertsExecutionResults.assert_unordered_result.<locals>.immutabledict.__hash__N)r   r   r   rw  r   r   r   r    immutabledictZ  r   rx  c                   s   h | ]} |qS r   r   )rF   e)rx  r   r    rW  _  r   zBAssertsExecutionResults.assert_unordered_result.<locals>.<setcomp>c                   s
   t |  S r4   r}   )o)clsr   r    <lambda>a  s   
 zAAssertsExecutionResults.assert_unordered_result.<locals>.<lambda>z#Unexpected type "%s", expected "%s"z+Unexpected object count "%s", expected "%s"c              	     st   |  D ]3\}}t|tr,zjt| ||d g|d R   W q ty+   Y  dS w t| | |kr7 dS qdS )Nr   r   FT)rr  r"   r&  assert_unordered_resultr   rI   )objr&   r   ru  )NOVALUEr   r   r    _compare_itemo  s   
zFAssertsExecutionResults.assert_unordered_result.<locals>._compare_itemz2Expected %s instance with attributes %s not found.T)dictr   IdentitySetr   r   rN   r   r2  r   remover"  )	r   r6  r{  ro   foundwrongr  expected_item
found_itemr   )r  r{  rx  r   r    r}  S  s<   


z/AssertsExecutionResults.assert_unordered_resultNc                 C  s   |d u r
ddl m} t|S )Nr   )r%   )r   r%   r   assert_engine)r   r%   r   r   r    sql_execution_asserter  s   
z.AssertsExecutionResults.sql_execution_asserterc                 G  s>   |  |}| }W d    n1 sw   Y  |j|  |S r4   r  r+   )r   r%   r   rulesasserterr6  r   r   r    assert_sql_execution  s
   
z,AssertsExecutionResults.assert_sql_executionc                 C  sZ   g }|D ]}t |trtjdd | D  }ntj| }|| q| j||g|R  S )Nc                 S  s   g | ]
\}}t ||qS r   )r   CompiledSQL)rF   kr	  r   r   r    rH     s    z6AssertsExecutionResults.assert_sql.<locals>.<listcomp>)r"   r  r   AllOfrr  r  r.  r  )r   r%   r   r  newrulesrulenewruler   r   r    
assert_sql  s   

z"AssertsExecutionResults.assert_sqlc                 C  s   |  ||t|S r4   )r  r   CountStatements)r   r%   r   countr   r   r    assert_sql_count  s   z(AssertsExecutionResults.assert_sql_countc                 g  s@    |  |}d V  W d    n1 sw   Y  |j|  d S r4   r  )r   r%   r  r  r   r   r    assert_execution  s
   z(AssertsExecutionResults.assert_executionc                 C  s   |  |t|S r4   )r  r   r  )r   r%   r  r   r   r    assert_statement_count  r   z.AssertsExecutionResults.assert_statement_countc           	      #  s     fddt ||D }g }|D ]\}}}||  qz"d V  W t ||D ]\}\}}}|d d d  |t| q(d S t ||D ]\}\}}}|d d d  |t| qFw )Nc                   s    g | ]\}}  |||fqS r   )r  )rF   r%   r  r   r   r    rH     s    zKAssertsExecutionResults.assert_statement_count_multi_db.<locals>.<listcomp>)r4  r.  	__enter____exit__r+   r   r  )	r   dbscountsrecs	assertersctxr%   r  r  r   r   r    assert_statement_count_multi_db  s    
z7AssertsExecutionResults.assert_statement_count_multi_dbr4   )r   r   r   rn  rk  ro  r}  r  r  r  r  
contextlibcontextmanagerr  r  r  r   r   r   r    rj  2  s    

6
rj  c                   @  s   e Zd Zd
ddZd	S )ComparesIndexesra  schema.Tablero   r]   dialect_namer#   c                 C  s  t t|jt| dd |jD }|D ]x}||d  }t |j|d  dd |d D }t t|jt| |D ]	}t||jv  q9|d}	|	rmt t|jt|	 t|j|	|d D ]\}
}}|d u rlt |
j	| q]|d	r| d
|d	 v rt |j
| d |d	 | d
  qd S )Nc                 S  s   i | ]}|j |qS r   r
  )rF   idxr   r   r    r    r   zEComparesIndexes.compare_table_index_with_expected.<locals>.<dictcomp>r  uniquec                 S  s   g | ]}|d ur|qS r4   r   )rF   r  r   r   r    rH     r  zEComparesIndexes.compare_table_index_with_expected.<locals>.<listcomp>column_namesexpressionsdialect_options_includeinclude)ry   r2  indexesr  r`  r   r,  r  r4  textr  )r   ra  ro   r  idx_dictexpr  colsr  exprsidx_expexprcolr   r   r    !compare_table_index_with_expected  s6   
z1ComparesIndexes.compare_table_index_with_expectedN)ra  r  ro   r]   r  r#   )r   r   r   r  r   r   r   r    r    s    r  )TFT)TFTFFr4   )NF)T)Q
__future__r   collectionsr   r  r   	itertoolsr   rB   r   rc   r   r   r   r	   r
   
exclusionsr   r   r   r   r   r   r   r   r  enginer   r   sql.selectabler   r   r!   r  r'   r3   r6   r9   r;   r<   r^   r_   rM   r   r@   rh   rg   rs   rw   ry   r{   r|   r~   r   r   r   r   r   r   is_not_r   r   not_in_r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ  rj  r  r   r   r   r    <module>   s   	

P
















*
  
6 