1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
U
¸ý°d¬~ã@sÎddlmZddlmZddlZddlmZddlmZddlZddl    Z    ddl
Z
ddl m Z ddl m Z dd    l mZdd
l mZdd lmZdd lmZd dl mZd dl mZd dl mZd dl mZd dl mZd dlmZd dlmZd dlmZd dlmZdd„Z ej!dd„ƒZ"dd„Z#dd„Z$dd „Z%d!d"„Z&d#d$„Z'da(da)da*dod'd(„Z+ej!dpd)d*„ƒZ,d+d,„Z-d-d.„Z.d/d0„Z/dqd1d2„Z0drd3d4„Z1dsd5d6„Z2dtd7d8„Z3dud9d:„Z4dvd;d<„Z5dwd=d>„Z6dxd?d@„Z7dydAdB„Z8dzdCdD„Z9d{dEdF„Z:e:Z;d|dGdH„Z<d}dIdJ„Z=e=Z>d~dKdL„Z?ddMdN„Z@dOdP„ZAdQdR„ZBdSdT„ZCdUdV„ZDdWdX„ZEdYdZ„ZFd[d\„ZGd€d]d^„ZHGd_d`„d`ƒZIej!ddadb„ƒZJd‚dcdd„ZKdƒdedf„ZLGdgdh„dhƒZMGdidj„djƒZNGdkdl„dlƒZOGdmdn„dnƒZPdS)„é)Ú annotations)Ú defaultdictN)Úcopy)Ú filterfalseé)Ú    assertsql)Úconfig)Úengines)Úmock)Údb_spec)Úfailé)Úexc)Úschema)Úsql)Útypes)Úutil)Údefault)Úurl)ÚLABEL_STYLE_TABLENAME_PLUS_COL©Ú    decoratorcOsttj|f|Ž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_excZ    SAWarning©ÚmessagesÚkw©rúTd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/testing/assertions.pyÚexpect_warnings%s rc    osDt|ƒ}t|tƒr$|tjƒs$dVnt||Ž dVW5QRXdS)z›Context 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)ÚdbrrÚspecrrrÚexpect_warnings_on5s
 r%cst‡fdd„ƒ}|S)z„Decorator form of expect_warnings().
 
    Note that emits_warning does **not** assert that the warnings
    were in fact seen.
 
    c
s0tˆddiŽ|||ŽW5QR£SQRXdS©NÚassert_F)r©ÚfnÚargsr©rrrÚdecorateNszemits_warning.<locals>.decorater©rr,rr+rÚ emits_warningFsr.cOsttj|f|ŽS©N)rrZSADeprecationWarningrrrrÚexpect_deprecatedVs ÿÿr0cOsttj|f|ŽSr/)rrZBase20DeprecationWarningrrrrÚexpect_deprecated_20\s ÿÿr1cst‡‡fdd„ƒ}|S)aVMark 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
s6tˆfˆžddiŽ|||ŽW5QR£SQRXdSr&)r%r(©r#rrrr,nsz"emits_warning_on.<locals>.decorater)r#rr,rr2rÚemits_warning_onbs r3cst‡fdd„ƒ}|S)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
s0tˆddiŽ|||ŽW5QR£SQRXdSr&)r0r(r+rrr,†sz!uses_deprecated.<locals>.decoraterr-rr+rÚuses_deprecatedvsr4TFcCst|||||ddS)zžSQLAlchemy 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_clsrr5r6r'rrrr“s úrc#sˆsˆrdd„|Dƒ‰nt|ƒ‰tdk    rftdk    s4t‚tdk    s@t‚t ˆ¡t ˆ¡t|f7adVnœtˆƒ‰aˆa|faˆrŠdd„‰ntj    ‰‡‡‡‡‡‡‡fdd„}t
  d|¡Hz
dVW5daaa|röˆrötdd      ‡fd
d „ˆDƒ¡ƒ‚XW5QRXdS) NcSs g|]}t |tjtjB¡‘qSr)ÚreÚcompileÚIÚS)Ú.0ÚmsgrrrÚ
<listcomp>·sz$_expect_warnings.<locals>.<listcomp>c_std|ƒ‚dS)NzGot unexpected warning: %r©ÚAssertionError)r?ÚargrrrrÚ    real_warnËsz#_expect_warnings.<locals>.real_warncs¸t|tƒrt|ƒ}t|ƒ}n|r*|d}nd}|r<t|tƒsTˆsPˆ|f|ž|ŽSdSˆs`ˆs`dSˆD]:}ˆrv| |¡sˆr„| |¡sˆsd||krdˆ |¡q´qdˆs´ˆ|f|ž|ŽdS)Nr)r Ú_EXC_CLSÚtyper!Ú
issubclassÚsearchÚmatchÚdiscard)r?rCrÚ    exceptionZfilter_©Úfiltersr7rDr5r6ÚseenÚsquelch_other_warningsrrÚour_warnÑs:
 
 
ÿÿþþýý
z"_expect_warnings.<locals>.our_warnz warnings.warnzWarnings were not seen: %sz, c3s |]}dˆr|jn|VqdS)z%rN)Úpattern)r>Ús)r5rrÚ    <genexpr>ösz#_expect_warnings.<locals>.<genexpr>) ÚlistÚ_FILTERSÚ_SEENrBrEÚextendÚupdateÚsetÚwarningsÚwarnr
ÚpatchÚjoin)r9rr5r6r'r7rOrPrrLrr8ªs2   
 
 
 
 
 ÿr8cCs
tƒdS)zÛCheck 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_connectionsrrrrÚglobal_cleanup_assertionsûsr_cCstj ¡dSr/)r    Ztesting_reaperZassert_all_closedrrrrr^sr^cCs6t||ƒ}t||ƒ|ks2td||d|fƒ‚dS)Nz:Given int value %s is not within %d%% of expected value %séd)ÚintÚabsrB)ÚexpectedZreceivedZvarianceZdeviancerrrÚint_within_variance
s ÿýþrdcCs$t ||¡s t|pd||fƒ‚dS)Nz%r !~ %r)r:rIrB©ÚaÚbr?rrrÚeq_regexsrhcCs ||kst|pd||fƒ‚dS)z.Assert a == b, with repr messaging on failure.ú%r != %rNrArerrrÚeq_srjcCs ||kst|pd||fƒ‚dS)z.Assert a != b, with repr messaging on failure.z%r == %rNrArerrrÚne_srkcCs ||kst|pd||fƒ‚dS)z.Assert a <= b, with repr messaging on failure.riNrArerrrÚle_#srlcCs"t||ƒst|pd||fƒ‚dS)Nz%r is not an instance of %r)r rBrerrrÚis_instance_of(srmcCst|d|ddS©N©r?)Úis_©rfr?rrrÚis_none,srrcCst|d|ddSrn)Úis_notrqrrrÚ is_not_none0srtcCstt|ƒd|ddS)NTro©rpÚboolrqrrrÚis_true4srwcCstt|ƒd|ddS)NFrorurqrrrÚis_false8srxcCs ||kst|pd||fƒ‚dS)z.Assert a is b, with repr messaging on failure.z %r is not %rNrArerrrrp<srpcCs ||k    st|pd||fƒ‚dS)z2Assert a is not b, with repr messaging on failure.z%r is %rNrArerrrrsAsrscCs ||kst|pd||fƒ‚dS)z.Assert a in b, with repr messaging on failure.z %r not in %rNrArerrrÚin_JsrycCs ||kst|pd||fƒ‚dS)z2Assert a in not b, with repr messaging on failure.z %r is in %rNrArerrrÚnot_inOsrzcCs"| |¡st|pd||fƒ‚dS)z>Assert a.startswith(fragment), with repr messaging on failure.z%r does not start with %rN)Ú
startswithrB)rfÚfragmentr?rrrÚ startswith_Xsþr}cCstt dd|¡}t dd|¡}t dd|¡}t dd|¡}t dd|¡}t dd|¡}||kspt|pld||fƒ‚dS)Nz^\s+?|\nÚz {2,}ú z\tri)r:ÚsubrBrerrrÚeq_ignore_whitespace`srcCs,|j|jk    r(|js(ds(td||jfƒ‚dS)aHassert 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__rB)rKrrrÚ _assert_proper_exception_contextks
ÿþþÿr…cOst||||ddS)NT©Ú check_context©Ú_assert_raises©Ú
except_clsÚ    callable_r*rrrrÚ assert_raises€srcOst||||ƒSr/rˆrŠrrrÚassert_raises_context_ok„srŽcOst|||||ddS)NT©r?r‡rˆ©r‹r?rŒr*ÚkwargsrrrÚassert_raises_messageˆsÿr’c
Os.t|dgƒ|||ŽW5QR£SQRXdS)alegacy 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‘rrrÚ assert_warnsŽs    r”c
Os4t||gddd|||ŽW5QR£SQRXdS)aqlegacy 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)r6r5Nr“rrrrÚassert_warns_message›s ür•cOst|||||dSrnrˆrrrrÚ assert_raises_message_context_ok¯sr–c    Cs(t|||ƒ}|||ŽW5QRX|jSr/)Ú_expect_raisesÚerror)r‹rŒr*r‘r?r‡Úecrrrr‰µsr‰c@seZdZdZdS)Ú_ErrorContainerN)Ú__name__Ú
__module__Ú __qualname__r˜rrrrrš½sršc
csÜt|tƒrt|tƒst|tƒr&tdƒ‚tƒ}|r<t ¡d}z|Vd}Wn~|k
rÈ}z`||_d}|dk    r–t    |ƒ}t
  ||t
j ¡s–t d||fƒ‚|r¦|s¦t|ƒtt    |ƒ d¡ƒW5d}~XYnX~|sØt dƒ‚dS)NzCUse expect_warnings for warnings, not expect_raises / assert_raisesrFTz%r !~ %súutf-8z#Callable did not raise an exception)r rFrGÚWarningÚ    TypeErrorršÚsysÚexc_infor˜r!r:rHÚUNICODErBr…ÚprintÚencode)r‹r?r‡r™Zare_we_already_in_a_tracebackÚsuccessÚerrZerror_as_stringrrrr—Ás:ÿþýÿ þ$r—cCs t||dS)Nr†©r—)r‹r‡rrrÚ expect_raisesìsr©cCst|||dS)Nrr¨)r‹r?r‡rrrÚexpect_raises_messageðsrªc@seZdZddd„ZdS)ÚAssertsCompiledSQLNFTc/    s | rt ¡‰| ˆ_|ˆ_n˜| r$d‰nŽˆdkr8t|ddƒ‰ˆdkrJtjj‰nhˆdksZˆdkr„ˆdkrlt ¡‰n
t d¡‰| ˆ_|ˆ_n.ˆdkr–t ¡‰nt    ˆt
ƒr²t j   ˆ¡ ¡ƒ‰|r¼|ˆ_i}i}|rÐ||d<|dk    rät|ƒ|d<|rðd|d    <|rüd|d
<|r
d|d <|rd|d <|r&d|d <|s:t|ddƒrDtj|d<ddlm}t    ||jƒrp| ¡}t|_|}|r~||d<Gdd„dƒ‰G‡fdd„dƒ}||ƒjfdˆi|—މt    |tjƒrÚ|j}|rôt|ƒn| ¡}|rôt|dƒttˆdiƒƒ}|  d¡ !dd¡}t"dt
ˆƒ|  d¡ƒt# $ddt
ˆƒ¡}t%||d ||ˆfƒ|dk    r”|r„ˆj&|dd!‰t%ˆj'|ƒnt%ˆ (|¡|ƒ|    dk    rþ|r҈j&|dd!‰t%t)‡fd"d#„ˆj*Dƒƒ|    ƒn,ˆj(|dd!‰t%t)‡fd$d#„ˆj*Dƒƒ|    ƒ|
dk    rt%ˆj+|
ƒ|dk    r8t%‡fd%d&„ˆj,Dƒ|ƒ|dk    r\t%‡fd'd&„ˆj-Dƒ|ƒ|rtˆddƒr‡fd(d)„}|d*dƒ} |jfd| i|—Ž}!t# $ddt
|!ƒ¡}|ddƒ}"|jfd|"i|—Ž}#t|#j*ƒ}$|#j.}%|#j-|#j,BD],}&|#j/|&‰ˆ|$kræ‡fd+d#„|$Dƒ}$qæg‰t0tƒ}'|$D]’}(zZ|(|'krB|'|(d,})nd})|% 1|(|(¡}*| 2d-|*f|)¡d.}+ˆ 3|+¡|'|( 3|+¡Wn0t4k
r²d/|(|f},ds®t5|,ƒ‚YnXq$t6‡fd0d1„t7d2t8ˆƒƒDƒƒ}-d3d#„t9t:ˆ|$ƒƒDƒ}.d4|$|.|f},t;|-|,ƒdS)5NZ __dialect__rZ default_qmarkZqmarkZdefault_enhancedÚschema_translate_mapZ column_keysTÚ literal_bindsÚrender_postcompileÚ"use_literal_execute_for_simple_intÚfor_executemanyÚrender_schema_translateZassert_from_lintingFZlintingr)ÚormÚcompile_kwargsc@seZdZdd„ZdS)z5AssertsCompiledSQL.assert_compile.<locals>.DontAccesscSs tdƒ‚dS)Nz=compiler accessed .statement; use compiler.current_executable)ÚNotImplementedError)ÚselfÚkeyrrrÚ__getattribute__OsÿzFAssertsCompiledSQL.assert_compile.<locals>.DontAccess.__getattribute__N)r›rœrr·rrrrÚ
DontAccessNsr¸csDeZdZdd„Zedd„ƒZdd„Zdd„Zd    d
„Z‡fd d „Z    d S)z>AssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccesscSsb||_i|_t|ddƒ|_|jr^|j|_t|dƒr:|j|_t|dƒrL|j|_t|dƒr^|j|_dS)NÚsupports_executionFÚ
_returningÚ_inlineÚ_return_defaults)    Útest_statementZ _annotationsÚgetattrr¹Z_execution_optionsÚhasattrrºr»r¼)rµr½rrrÚ__init__Vsÿ
 
 
zGAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess.__init__cSs|jjSr/)r½Ú_variant_mapping©rµrrrrÁgszOAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess._variant_mappingcSs
|j ¡Sr/)r½Ú_default_dialectrÂrrrrÃkszOAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess._default_dialectc[s|jjj|fd|i|—ŽS)NÚdialect)r½r;Ú__func__©rµrÄrrrrr;nsÿÿÿzFAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess.compilec[s|jjj||f|ŽSr/)r½Ú    _compilerrÅrÆrrrrÇss ÿÿzHAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess._compilerc
sVt|dƒrBtj |dˆƒ¡|jj|f|ŽW5QR£SQRXn|jj|f|ŽSdS)NZ    statement)r¿r
r\Úobjectr½Ú_compiler_dispatch)rµÚcompilerr‘©r¸rrrÉxs 
ÿÿÿÿÿzQAssertsCompiledSQL.assert_compile.<locals>.CheckCompilerAccess._compiler_dispatchN)
r›rœrrÀÚpropertyrÁrÃr;rÇrÉrrËrrÚCheckCompilerAccessUs
rÍrÄÚparamsržÚasciiÚignorez
SQL String:
z[\n\t]r~z%r != %r on dialect %r)Z escape_namescsg|]}ˆj|‘qSr)Ú
parameters©r>Úx)Úexpanded_staterrr@ªsÿz5AssertsCompiledSQL.assert_compile.<locals>.<listcomp>csg|] }ˆ|‘qSrrrÒ)Úprrr@³scsi|]}ˆj||j“qSr©Ú
bind_namesZeffective_value©r>rg©ÚcrrÚ
<dictcomp>¸sÿz5AssertsCompiledSQL.assert_compile.<locals>.<dictcomp>csi|]}ˆj||j“qSrrÖrØrÙrrrÛÀsÿcstˆƒ}||_||_|Sr/)rÚ
paramstyleÚ
positional)rÜrÝÚcp)rÄrrÚ get_dialectÈsz6AssertsCompiledSQL.assert_compile.<locals>.get_dialectZpyformatcsg|]}|ˆkr|‘qSrr)r>Úv©Únamerrr@Üséÿÿÿÿz%%(%s)sr z#Expected to find bindparam %r in %rc3s"|]}ˆ|dˆ|kVqdS)rNr)r>Úi)Ú    positionsrrrSísÿz4AssertsCompiledSQL.assert_compile.<locals>.<genexpr>rcSsg|] \}}|‘qSrr)r>Ú_ràrrrr@òszQOrder of parameters %s does not match the order in the statement %s. Statement %r)<rZDefaultDialectÚsupports_default_valuesÚsupports_default_metavaluer¾rr#rÄZStrCompileDialectr r!rÚURLÚcreaterßÚdefault_schema_namerTrZ FROM_LINTINGZ
sqlalchemyr²ZQueryZ _statement_20rZ _label_styler;ÚsqltypesZ
TypeEngineZ_static_cache_keyÚhashZ_generate_cache_keyÚreprr¥Údecoder¤r:r€rjZconstruct_expanded_staterÑZconstruct_paramsÚtupleZ positiontupZprefetchZliteral_execute_paramsZpost_compile_paramsZescaped_bind_namesr×rÚgetÚindexÚappendÚ
ValueErrorrBÚallÚrangeÚlenÚsortedÚziprw)/rµZclauseÚresultrÎZ checkparamsr°Zcheck_literal_executeZcheck_post_paramrÄZcheckpositionalZcheck_prefetchZuse_default_dialectZallow_dialect_selectrçrèr­r®r¬r±rëZ from_lintingZcheck_param_orderr¯rr³r²ZstmtrÍZcache_key_no_warningsZ    param_strÚccrßZpyformat_dialectZ
pyformat_cZ qmark_dialectZqmark_cÚvaluesÚescapedZ
post_paramZ pos_by_valueràÚstartÚescÚposr?Zorderedrcr)r¸rÚrÄrÔrârÕrårÚassert_compileõs 
 
 
 
 
 
 3
 
ÿ
ÿ
þÿù
 
 
 
þû
 
þû 
 
 
 
ÿ
 
 
 
   þÿÿz!AssertsCompiledSQL.assert_compile)NNFNNNNNFFTTFFNFNFTF)r›rœrrrrrrr«ôs*ér«c@seZdZddd„Zdd„ZdS)    ÚComparesTablesFTcCsVt|jƒt|jƒkst‚t|j|jƒD]ä\}}t|j|jƒ||j|jksPt‚|rpt|j|jƒt|j|jƒ|r d}t|j    t    |j    ƒƒs¬t||j    |j    fƒ‚n | 
||¡t|j    t j ƒrÌt|j    j |j    j ƒ|ròtdd„|jDƒdd„|jDƒƒ|jr&t|jtjƒs&t‚q&|rRt|jƒt|jƒks,t‚|jD]}|jj|jdk    s2t‚q2dS)Nz)Type '%s' doesn't correspond to type '%s'cSsh|] }|jj’qSr©Úcolumnrâ©r>ÚfrrrÚ    <setcomp>sz5ComparesTables.assert_tables_equal.<locals>.<setcomp>cSsh|] }|jj’qSrrrrrrrs)r÷rÚrBrùrjrâZ primary_keyZnullabler rFÚassert_types_baserìÚStringÚlengthZ foreign_keysZserver_defaultrZ FetchedValueÚcolumns)rµÚtableZreflected_tableÚ strict_typesZstrict_constraintsrÚZ reflected_cr?rrrÚassert_tables_equalýs<þ
 þÿ
 
z"ComparesTables.assert_tables_equalcCs*|j |j¡s&td|j|j|jfƒ‚dS)Nz7On column %r, type '%s' doesn't correspond to type '%s')rFZ_compare_type_affinityrBrâ)rµZc1Úc2rrrr(sÿýþz ComparesTables.assert_types_baseN)FT)r›rœrrrrrrrrüsû
+rc@sreZdZdd„Zdd„Zdd„Zdd„Zdd
d „Zd d „Zdd„Z    dd„Z
e j dd„ƒZ dd„Ze j dd„ƒZd    S)ÚAssertsExecutionResultscGs&t|ƒ}tt|ƒƒ| |||¡dSr/)rTr¤rîÚ assert_list)rµrúÚclass_ZobjectsrrrÚ assert_result3s z%AssertsExecutionResults.assert_resultcCsL| t|ƒt|ƒkd|j¡tdt|ƒƒD]}| |||||¡q,dS)Nz9result list is not the same size as test list, for class r)r'r÷r›röÚ
assert_row)rµrúrÚlist_rärrrr8sþþz#AssertsExecutionResults.assert_listc    Csª| |j|kdt|ƒ¡| ¡D]‚\}}t|tƒr~t|dtƒr`| t||ƒ|d|d¡q¤|     |dt||ƒ|d¡q"| t||ƒ|kd|t||ƒ|f¡q"dS)Nzitem class is not rrz'attribute %s value %s does not match %s)
r'Ú    __class__rîÚitemsr rðrTrr¾r)rµrZrowobjÚdescr¶ÚvaluerrrrBs
ÿ
 ÿþz"AssertsExecutionResults.assert_rowc    sÞGdd„dtƒ‰t |¡}‡fdd„|Dƒ}t‡fdd„|ƒD]}tdt|ƒjˆjfƒq>t|ƒt|ƒkr„tdt|ƒt|ƒfƒtƒ‰‡‡fd    d
„}|D]<}|D]}|||ƒr¤|     |¡qœq¤td ˆjt
|ƒfƒqœd S) zÉAs 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@seZdZdd„ZdS)zFAssertsExecutionResults.assert_unordered_result.<locals>.immutabledictcSst|ƒSr/)ÚidrÂrrrÚ__hash__[szOAssertsExecutionResults.assert_unordered_result.<locals>.immutabledict.__hash__N)r›rœrrrrrrÚ immutabledictZsrcsh|] }ˆ|ƒ’qSrr)r>Úe)rrrr_szBAssertsExecutionResults.assert_unordered_result.<locals>.<setcomp>cs
t|ˆƒSr/)r )Úo)ÚclsrrÚ<lambda>aózAAssertsExecutionResults.assert_unordered_result.<locals>.<lambda>z#Unexpected type "%s", expected "%s"z+Unexpected object count "%s", expected "%s"c    sv| ¡D]h\}}t|tƒrZz$ˆjt||ƒ|df|džŽWqptk
rVYdSXqt||ˆƒ|krdSqdS)NrrFT)rr rðÚassert_unordered_resultr¾rB)Úobjr$r¶r)ÚNOVALUErµrrÚ _compare_itemos
ÿÿ
 zFAssertsExecutionResults.assert_unordered_result.<locals>._compare_itemz2Expected %s instance with attributes %s not found.T) ÚdictrZ IdentitySetrr rFr›r÷rÈÚremoverî)    rµrúrrcÚfoundZwrongr%Z expected_itemZ
found_itemr)r$rrrµrr"Ss8
ÿÿÿÿ
 
 ÿÿz/AssertsExecutionResults.assert_unordered_resultNcCs|dkrddlm}t |¡S)Nr)r#)r~r#rZ assert_engine)rµr#rrrÚsql_execution_asserter‰s z.AssertsExecutionResults.sql_execution_asserterc    Gs*| |¡ }|ƒ}W5QRX|j|Ž|Sr/©r)r')rµr#rŒÚrulesÚasserterrúrrrÚassert_sql_executions 
z,AssertsExecutionResults.assert_sql_executioncCsXg}|D]<}t|tƒr0tjdd„| ¡DƒŽ}n
tj|Ž}| |¡q|j||f|žŽS)NcSsg|]\}}t ||¡‘qSr)rÚ CompiledSQL)r>Úkràrrrr@šsz6AssertsExecutionResults.assert_sql.<locals>.<listcomp>)r r&rZAllOfrr.rór-)rµr#rŒr+ZnewrulesZruleZnewrulerrrÚ
assert_sql•s
ÿ
 z"AssertsExecutionResults.assert_sqlcCs| ||t |¡¡Sr/)r-rÚCountStatements)rµr#rŒÚcountrrrÚassert_sql_count¢s
ÿz(AssertsExecutionResults.assert_sql_countc    gs*| |¡ }dVW5QRX|j|ŽdSr/r*)rµr#r+r,rrrÚassert_execution§s z(AssertsExecutionResults.assert_executioncCs| |t |¡¡Sr/)r4rr1)rµr#r2rrrÚassert_statement_count­sz.AssertsExecutionResults.assert_statement_countc     #s„‡fdd„t||ƒDƒ}g}|D]\}}}| | ¡¡q z
dVW5t||ƒD],\}\}}}| ddd¡| t |¡¡qPXdS)Ncs g|]\}}ˆ |¡||f‘qSr)r))r>r#r2rÂrrr@²sÿzKAssertsExecutionResults.assert_statement_count_multi_db.<locals>.<listcomp>)rùróÚ    __enter__Ú__exit__r'rr1)    rµZdbsÚcountsZrecsZ    assertersÚctxr#r2r,rrÂrÚassert_statement_count_multi_db°s
þ
z7AssertsExecutionResults.assert_statement_count_multi_db)N)r›rœrrrrr"r)r-r0r3Ú
contextlibÚcontextmanagerr4r5r:rrrrr2s
6
 
rc@seZdZddddœdd„ZdS)ÚComparesIndexesz schema.TablerTr!)r rcÚ dialect_namec Cstt|jƒt|ƒƒdd„|jDƒ}|D]ð}||d}t|j|dƒdd„|dDƒ}tt|jƒt|ƒƒ|D]}t||jkƒqr| d¡}    |    rÚtt|jƒt|    ƒƒt|j|    |dƒD]\}
} } | dkrºt|
j    | ƒqº| d    ¡r(|›d
|d    kr(t|j
|d |d    |›d
ƒq(dS) NcSsi|] }|j|“qSrrá)r>ÚidxrrrrÛÆszEComparesIndexes.compare_table_index_with_expected.<locals>.<dictcomp>râÚuniquecSsg|]}|dk    r|‘qSr/r)r>rÚrrrr@ÊszEComparesIndexes.compare_table_index_with_expected.<locals>.<listcomp>Z column_namesÚ expressionsÚdialect_optionsZ_includeÚinclude) rjr÷Zindexesr@r rwrñrArùÚtextrB) rµr rcr>Zidx_dictÚexpr?ÚcolsrÚÚexprsZidx_expÚexprÚcolrrrÚ!compare_table_index_with_expectedÂs6 
ÿÿþ þz1ComparesIndexes.compare_table_index_with_expectedN)r›rœrrJrrrrr=Ásr=)TFT)TFTFF)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)NF)NF)T)T)QÚ
__future__rÚ collectionsrr;rÚ    itertoolsrr:r¡rZr~rrr    r
Z
exclusionsr rr rrrrrrìZenginerrZsql.selectablerrrr<r%r.r0r1r3r4rUrVrErr8r_r^rdrhrjrkrlrmrrrtrwrxrprsZis_not_ryrzZnot_in_r}rr…rrŽr’r”r•r–r‰ršr—r©rªr«rrr=rrrrÚ<module>
s¬                   
û
ù P 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ÿ
 *
 

6