Files
Home-AssistantConfig/deps/sqlalchemy/testing/__pycache__/assertions.cpython-34.pyc

107 lines
17 KiB
Plaintext
Raw Normal View History

2016-10-11 16:42:06 +00:00
<EFBFBD>
}<7D><>W<EFBFBD>><00>@sXddlmZddlmZddlmZmZmZddlm Z m
Z
ddl m Z ddlm ZmZmZddlZddlZdd lmZmZdd
lmZdd lmZdd lmZddlZdd lmZdd<00>Zejdd<00><00>Zdd<00>Zdd<00>Z dd<00>Z!dd<00>Z"ejdddd<00><00>Z#dd<00>Z$da%dd <00>Z&dd!d"<00>Z'dd#d$<00>Z(dd%d&<00>Z)dd'd(<00>Z*dd)d*<00>Z+dd+d,<00>Z,dd-d.<00>Z-dd/d0<00>Z.d1d2<00>Z/d3d4<00>Z0Gd5d6<00>d6e1<00>Z2Gd7d8<00>d8e1<00>Z3Gd9d:<00>d:e1<00>Z4dS);<3B>)<01>absolute_import<72>)<01>util)<03>pool<6F>ormr)<02>default<6C>url)<01> decorator)<03>types<65>schema<6D>excN)<02>db_spec<65> _is_excluded)<01> assertsql)<01>config)<01>fail)<01>mockcOsttj||<00>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.
)<03>_expect_warnings<67>sa_excZ SAWarning)<02>messages<65>kw<6B>r<00>C/tmp/pip-build-zkr322cu/sqlalchemy/sqlalchemy/testing/assertions.py<70>expect_warningss rcosUt|<00>}t|tj<00>r6|tj<00> r6dVnt||<00><00>
dVWdQXdS)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 <00>
isinstancer<00> string_typesr<00>_currentr)<04>dbrr<00>specrrr<00>expect_warnings_on)s
 "rcst<00>fdd<00><00>}|S)z<>Decorator form of expect_warnings().
Note that emits_warning does **not** assert that the warnings
were in fact seen.
c
s*tdd<00><00><01>|||<00>SWdQXdS)N<>assert_F)r)<03>fn<66>argsr)rrr<00>decorateBszemits_warning.<locals>.decorate)r )rr#r)rr<00> emits_warning:sr$cOsttj||<00>S)N)rrZSADeprecationWarning)rrrrr<00>expect_deprecatedJsr%cst<00><00>fdd<00><00>}|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
s-t<00>dd<00><00><01>|||<00>SWdQXdS)Nr F)r)r!r"r)rrrrr#Ysz"emits_warning_on.<locals>.decorate)r )rrr#r)rrr<00>emits_warning_onNs r&cst<00>fdd<00><00>}|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
s*tdd<00><00><01>|||<00>SWdQXdS)Nr F)r%)r!r"r)rrrr#qsz!uses_deprecated.<locals>.decorate)r )rr#r)rr<00>uses_deprecatedasr'Tc #s<><00>rdd<00>|D<><00>n|<00>t<00><00><00>tj<00><00><00><00><00><00>fdd<00>}tjd|<00><00>
dVWdQX|r<><00> s<>tddj<00>fdd <00><00>D<><00><16><00>ndS)
NcSs,g|]"}tj|tjtjB<><00>qSr)<04>re<72>compile<6C>I<>S)<02>.0<EFBFBD>msgrrr<00>
<listcomp>|s z$_expect_warnings.<locals>.<listcomp>cs<>t|<00><00>s"<00>||||<00>S<>s,dSxZ<00>D]?}<00>rN|j|<00>sa<00> r3||kr3<00>j|<00>Pq3q3W<>||||<00>dS)N)<03>
issubclass<EFBFBD>match<63>discard)r-<00> exception<6F>argrZfilter_)<05>exc_cls<6C>filters<72> real_warn<72>regex<65>seenrr<00>our_warn<72>s  z"_expect_warnings.<locals>.our_warnz warnings.warnzWarnings were not seen: %sz, c3s(|]}d<00>r|jn|VqdS)z%rN)<01>pattern)r,<00>s)r7rr<00> <genexpr><3E>sz#_expect_warnings.<locals>.<genexpr>)<07>set<65>warnings<67>warnr<00>patch<63>AssertionError<6F>join)r4rr7r r9r)r4r5r6r7r8rrxs    rcCs t<00>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)<01>!_assert_no_stray_pool_connectionsrrrr<00>global_cleanup_assertions<6E>srDcCs<>tj<00>tjrAtd7atdttj<00><16>tj<00>ntjr<>ttj<00>}tjj<00>dads<>t d|<16><00>n'tdkr<>ds<>t d<00><00>dandS)Nrz2Encountered a stray connection in test cleanup: %srFz8Stray connection refused to leave after gc.collect(): %s<>
z*Encountered more than 10 stray connections)
<EFBFBD>testutilZlazy_gcrZ_refs<66>_STRAY_CONNECTION_FAILURES<45>print<6E>strZ
gc_collect<EFBFBD>clearrA)<01>errrrrrC<00>s
 
      rCcCs,||ks(t|p"d||f<16><00>dS)z.Assert a == b, with repr messaging on failure.z%r != %rN)rA)<03>a<>br-rrr<00>eq_<71>srNcCs,||ks(t|p"d||f<16><00>dS)z.Assert a != b, with repr messaging on failure.z%r == %rN)rA)rLrMr-rrr<00>ne_<65>srOcCs,||ks(t|p"d||f<16><00>dS)z.Assert a <= b, with repr messaging on failure.z%r != %rN)rA)rLrMr-rrr<00>le_<65>srPcCs,||ks(t|p"d||f<16><00>dS)z.Assert a is b, with repr messaging on failure.z %r is not %rN)rA)rLrMr-rrr<00>is_<73>srQcCs,||k s(t|p"d||f<16><00>dS)z2Assert a is not b, with repr messaging on failure.z%r is %rN)rA)rLrMr-rrr<00>is_not_<74>srRcCs,||ks(t|p"d||f<16><00>dS)z.Assert a in b, with repr messaging on failure.z %r not in %rN)rA)rLrMr-rrr<00>in_<6E>srScCs,||ks(t|p"d||f<16><00>dS)z2Assert a in not b, with repr messaging on failure.z %r is in %rN)rA)rLrMr-rrr<00>not_in_<6E>srTcCs/|j|<00>s+t|p%d||f<16><00>dS)z>Assert a.startswith(fragment), with repr messaging on failure.z%r does not start with %rN)<02>
startswithrA)rL<00>fragmentr-rrr<00> startswith_<68>srWc OsHy|||<00>d}Wn|k
r1d}YnX|sDtd<00><00>dS)NFTz#Callable did not raise an exception)rA)<05>
except_cls<EFBFBD> callable_r"r<00>successrrr<00> assert_raises<65>s  
  r[cOs<>y#|||<00>ds"td<00><00>Wnx|k
r<>}zXtj|tj|<00>tj<00>sotd||f<16><00>ttj|<00>jd<00><00>WYdd}~XnXdS)NFz#Callable did not raise an exceptionz%r !~ %szutf-8)rAr(<00>searchr<00> text_type<70>UNICODErH<00>encode)rXr-rYr"<00>kwargs<67>errr<00>assert_raises_messages 1rbc
@s4eZdZdddddddddd<00>ZdS)<05>AssertsCompiledSQLNFc s<>|rtj<00>}n<>| r$d}n<>|dkrEt|dd<00>}n|dkr`tjj}nH|dkr{tj<00>}n-t|tj<00>r<>t j
|<00>j <00><00>}ni} i} |dk r<>t |<00>| d<n|
r<>d| d<nt|t j<00>r|j<00>} d| j_| j}n| r/| | d<n|jd|| <00>}tt|di<00><00>}tjr<>|jd <00>jd
d <00>}td tj|<00>|jd <00><00>n$td tj|<00>jd <00>|<17>tjd dtj|<00><00>}t||d|||f<16>|dk r+t|j|<00>|<00>n|dk rr|j|<00><00>tt<00>fdd<00>|jD<><00>|<00>n|dk r<>t|j|<00>ndS)NZ __dialect__rZ column_keysT<73> literal_binds<64>compile_kwargs<67>dialect<63>paramszutf-8<>ascii<69>ignorez
SQL String:
z[\n\t]<5D>z%r != %r on dialect %rcsg|]}<00>|<19>qSrr)r,<00>x)<01>prrr.Ms z5AssertsCompiledSQL.assert_compile.<locals>.<listcomp>) rZDefaultDialect<63>getattrrrrfrrrr<00>URL<52> get_dialect<63>listrZQueryZ_compile_contextZ statementZ
use_labelsr)<00>reprZpy3kr_<00>decoderHr]r(<00>subrNZconstruct_params<6D>tupleZ positiontup<75>prefetch)<11>selfZclause<73>resultrgZ checkparamsrfZcheckpositionalZcheck_prefetchZuse_default_dialectZallow_dialect_selectrdrre<00>context<78>cZ param_str<74>ccr)rlr<00>assert_compilesT           $  , z!AssertsCompiledSQL.assert_compile)<04>__name__<5F>
__module__<EFBFBD> __qualname__r{rrrrrc s rcc@s+eZdZddd<00>Zdd<00>ZdS)<07>ComparesTablesFcCs<>t|j<00>t|j<00>ks$t<00>x_t|j|j<00>D]H\}}t|j|j<00>||j|jksut<00>t|j|j<00>t|j|j<00>|r<>d}t|j t |j <00><00>s<>t||j |j f<16><00>n|j
||<00>t|j t j <00>r"t|j j |j j <00>nttdd<00>|jD<><00>tdd<00>|jD<><00><00>|jr:t|jtj<00>s<>t<00>q:q:Wt|j<00>t|j<00>ks<>t<00>x0|jD]%}|jj|jdk s<>t<00>q<>WdS)Nz)Type '%s' doesn't correspond to type '%s'cSsg|]}|jj<00>qSr)<02>column<6D>name)r,<00>frrrr.gs z6ComparesTables.assert_tables_equal.<locals>.<listcomp>cSsg|]}|jj<00>qSr)r<>r<>)r,r<>rrrr.hs )<14>lenryrA<00>ziprNr<>Z primary_keyZnullabler<00>type<70>assert_types_base<73>sqltypes<65>String<6E>lengthr=Z foreign_keysZserver_defaultr Z FetchedValue<75>columns)rv<00>tableZreflected_tableZ strict_typesryZ reflected_cr-rrr<00>assert_tables_equalTs,$"  $z"ComparesTables.assert_tables_equalcCs;|jj|j<00>s7td|j|j|jf<16><00>dS)Nz7On column %r, type '%s' doesn't correspond to type '%s')r<>Z_compare_type_affinityrAr<>)rv<00>c1<63>c2rrrr<>rsz ComparesTables.assert_types_baseN)r|r}r~r<>r<>rrrrrRs rc@s<>eZdZdd<00>Zdd<00>Zdd<00>Zdd<00>Zd d
d <00>Zd d <00>Zdd<00>Z dd<00>Z
e j dd<00><00>Z dd<00>Zd S)<16>AssertsExecutionResultscGs3t|<00>}tt|<00><00>|j|||<00>dS)N)rprHrq<00> assert_list)rvrw<00>class_Zobjectsrrr<00> assert_resultys z%AssertsExecutionResults.assert_resultcCsl|jt|<00>t|<00>kdd|j<17>x8tdt|<00><00>D]!}|j|||||<19>qCWdS)Nz/result list is not the same size as test list, z
for class r)r r<>r|<00>range<67>
assert_row)rvrwr<>rp<00>irrrr<>~sz#AssertsExecutionResults.assert_listcCs<>|j|j|kdt|<00><17>x<>|j<00>D]<5D>\}}t|t<00>r<>t|dt<00>r<>|jt||<00>|d|d<19>q<>|j |dt||<00>|d<19>q0|jt||<00>|kd|t||<00>|f<16>q0WdS)Nzitem class is not rrz'attribute %s value %s does not match %s)
r <00> __class__rq<00>itemsrrtrpr<>rmr<>)rvr<>Zrowobj<62>desc<73>key<65>valuerrrr<><00>s''z"AssertsExecutionResults.assert_rowc sIGdd<00>dt<00><00>tj|<00>}t<00>fdd<00>|D<><00>}xFtj<00>fdd<00>|<00>D]&}tdt|<00>j<00>jf<16>qcWt|<00>t|<00>kr<>tdt|<00>t|<00>f<16>nt <00><00><00><00>fd d
<00>}x\|D]T}xK|D]&}|||<00>r<>|j
|<00>Pq<50>q<>Wtd <00>jt |<00>f<16>q<>Wd 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<00>ZdS)zFAssertsExecutionResults.assert_unordered_result.<locals>.immutabledictcSs
t|<00>S)N)<01>id)rvrrr<00>__hash__<5F>szOAssertsExecutionResults.assert_unordered_result.<locals>.immutabledict.__hash__N)r|r}r~r<>rrrr<00> immutabledict<63>s r<>csg|]}<00>|<00><00>qSrr)r,ra)r<>rrr.<00>s zCAssertsExecutionResults.assert_unordered_result.<locals>.<listcomp>cs t|<00><00>S)N)r)<01>o)<01>clsrr<00><lambda><3E>szAAssertsExecutionResults.assert_unordered_result.<locals>.<lambda>z#Unexpected type "%s", expected "%s"z+Unexpected object count "%s", expected "%s"c s<>x<>|j<00>D]{\}}t|t<00>rly(<00>jt||<00>|d|d<19>Wq<57>tk
rhdSYq<59>Xq t||<00><00>|kr dSq WdS)NrrFT)r<>rrt<00>assert_unordered_resultrmrA)<04>objrr<>r<>)<02>NOVALUErvrr<00> _compare_item<65>s"  zFAssertsExecutionResults.assert_unordered_result.<locals>._compare_itemz2Expected %s instance with attributes %s not found.T) <0C>dictrZ IdentitySetr=Zitertools_filterfalserr<>r|r<><00>object<63>removerq) rvrwr<><00>expected<65>foundZwrongr<67>Z expected_itemZ
found_itemr)r<>r<>r<>rvrr<><00>s*     z/AssertsExecutionResults.assert_unordered_resultNcCs,|dkrddlm}ntj|<00>S)Nr)r)rjrrZ assert_engine)rvrrrr<00>sql_execution_asserter<65>s z.AssertsExecutionResults.sql_execution_assertercGs0|j|<00><00>}|<00>WdQX|j|<00>dS)N)r<>r )rvrrY<00>rules<65>asserterrrr<00>assert_sql_execution<6F>s z,AssertsExecutionResults.assert_sql_executioncCs~g}x^|D]V}t|t<00>rGtjdd<00>|j<00>D<><00>}ntj|<00>}|j|<00>q W|j|||<00>dS)NcSs(g|]\}}tj||<00><00>qSr)r<00> CompiledSQL)r,<00>k<>vrrrr.<00>s z6AssertsExecutionResults.assert_sql.<locals>.<listcomp>)rr<>rZAllOfr<66>r<><00>appendr<64>)rvrrYr<>ZnewrulesZruleZnewrulerrr<00>
assert_sql<EFBFBD>s z"AssertsExecutionResults.assert_sqlcCs |j||tj|<00><00>dS)N)r<>r<00>CountStatements)rvrrY<00>countrrr<00>assert_sql_count<6E>sz(AssertsExecutionResults.assert_sql_countc
gs;tjj|<00>zdVtjj<00>Wdtjj<00>XdS)N)rr<>Z add_rulesZstatement_completeZ clear_rules)rvr<>rrr<00>assert_execution<6F>s
z(AssertsExecutionResults.assert_executioncCs|jtj|<00><00>S)N)r<>rr<>)rvr<>rrr<00>assert_statement_count<6E>sz.AssertsExecutionResults.assert_statement_count)r|r}r~r<>r<>r<>r<>r<>r<>r<>r<><00>
contextlib<EFBFBD>contextmanagerr<72>r<>rrrrr<>xs     1    r<>)5<>
__future__rrjrrFZ
sqlalchemyrrZsqlalchemy.enginerrZsqlalchemy.utilr r
r<>r r rr>r(Z
exclusionsr rrrrr<>rrr<>rr$r%r&r'rrDrGrCrNrOrPrQrRrSrTrWr[rbr<>rcrr<>rrrr<00><module>sJ        "
 '
E&