ó ÃÌ4]c@@sŽddlmZddlZddlZddlZddlmZddlmZddlmZddlm Z ddl m Z dd l m Z d d lmZd d lmZd d lmZd dlmZd dlmZd dlm Z d dlmZd dlmZd dl mZd dl mZd„Zejd„ƒZd„Zd„Zd„Zd„Z eje!e!e"d„ƒZ#d„Z$da%d„Z&dd„Z(dd„Z)dd„Z*dd „Z+dd!„Z,dd"„Z-dd#„Z.dd$„Z/dd%„Z0dd&„Z1dd'„Z2dd(„Z3d)„Z4d*„Z5d+e6fd,„ƒYZ7d-e6fd.„ƒYZ8d/e6fd0„ƒYZ9dS(1i(tabsolute_importNi(t assertsql(tconfig(tmock(tutil(tdb_spec(tfaili(texc(torm(tpool(tschema(ttypes(tdefault(turl(tcompat(t decoratorcO@sttj||S(sÊ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. (t_expect_warningstsa_exct SAWarning(tmessagestkw((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytexpect_warnings s co@sUt|ƒ}t|tjƒr6|tjƒ r6dVnt||Ž dVWdQXdS(s›Context manager which expects one or more warnings on specific dialects. The expect version **asserts** that the warnings were in fact seen. N(Rt isinstanceRt string_typesRt_currentR(tdbRRtspec((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytexpect_warnings_on0s  "c@st‡fd†ƒ}|S(s„Decorator form of expect_warnings(). Note that emits_warning does **not** assert that the warnings were in fact seen. c@s*tdtˆŒ|||ŽSWdQXdS(Ntassert_(RtFalse(tfntargsR(R(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytdecorateIs(R(RR ((RsP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyt emits_warningAscO@sttj||S(N(RRtSADeprecationWarning(RR((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytexpect_deprecatedQsc@st‡‡fd†ƒ}|S(sVMark 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ˆdtˆŒ|||ŽSWdQXdS(NR(RR(RRR(RR(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR as(R(RRR ((RRsP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytemits_warning_onUs c@st‡fd†ƒ}|S(s+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*tdtˆŒ|||ŽSWdQXdS(NR(R#R(RRR(R(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR ys(R(RR ((RsP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytuses_deprecatedisc#@sÚˆr8g|D]"}tj|tjtjBƒ^q ‰n|‰tˆƒ‰tj‰‡‡‡‡‡fd†}tjd|ƒ dVWdQX|rÖ| s£t j rÖˆ sÖt ddj ‡fd†ˆDƒƒƒ‚ndS(Nc@sÌt|ˆƒr$|}t|ƒ}n|r7|d}nd}| sTt|ˆƒ rdˆ|||ŽSˆsndSxWˆD]?}ˆr|j|ƒs£ˆ ru||kruˆj|ƒPququWˆ|||ŽdS(Ni(RtstrtNonet issubclasstmatchtdiscard(tmsgtargRt exceptiontfilter_(texc_clstfilterst real_warntregextseen(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytour_warns    s warnings.warnsWarnings were not seen: %ss, c3@s(|]}dˆr|jn|VqdS(s%rN(tpattern(t.0ts(R2(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pys «s( tretcompiletItStsettwarningstwarnRtpatchRtpy3ktAssertionErrortjoin(R/RR2Rtpy2konlyR+R4((R/R0R1R2R3sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyRs2   cC@s tƒdS(sÛ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(t!_assert_no_stray_pool_connections(((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytglobal_cleanup_assertions¯scC@s¦tjƒtjr<td7adttjƒGHtjƒntjr{ttjƒ}tjjƒdatj d|ƒn'tdkr¢t s™t dƒ‚dandS(Nis2Encountered a stray connection in test cleanup: %sis8Stray connection refused to leave after gc.collect(): %si s*Encountered more than 10 stray connections( ttestutiltlazy_gcR t_refst_STRAY_CONNECTION_FAILURESR&t gc_collecttclearR=R>RRA(terr((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyRD½s       cC@s2tj||ƒs.t|p(d||fƒ‚dS(Ns%r !~ %r(R8R)RA(tatbR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyteq_regexçscC@s,||ks(t|p"d||fƒ‚dS(s.Assert a == b, with repr messaging on failure.s%r != %rN(RA(RMRNR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyteq_ëscC@s,||ks(t|p"d||fƒ‚dS(s.Assert a != b, with repr messaging on failure.s%r == %rN(RA(RMRNR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytne_ðscC@s,||ks(t|p"d||fƒ‚dS(s.Assert a <= b, with repr messaging on failure.s%r != %rN(RA(RMRNR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytle_õscC@st|td|ƒdS(NR+(tis_tTrue(RMR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytis_trueúscC@st|td|ƒdS(NR+(RSR(RMR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytis_falseþscC@s,||ks(t|p"d||fƒ‚dS(s.Assert a is b, with repr messaging on failure.s %r is not %rN(RA(RMRNR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyRSscC@s,||k s(t|p"d||fƒ‚dS(s2Assert a is not b, with repr messaging on failure.s%r is %rN(RA(RMRNR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytis_not_scC@s,||ks(t|p"d||fƒ‚dS(s.Assert a in b, with repr messaging on failure.s %r not in %rN(RA(RMRNR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytin_ scC@s,||ks(t|p"d||fƒ‚dS(s2Assert a in not b, with repr messaging on failure.s %r is in %rN(RA(RMRNR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytnot_in_scC@s/|j|ƒs+t|p%d||fƒ‚dS(s>Assert a.startswith(fragment), with repr messaging on failure.s%r does not start with %rN(t startswithRA(RMtfragmentR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyt startswith_scC@s€tjdd|ƒ}tjdd|ƒ}tjdd|ƒ}tjdd|ƒ}||ks|t|pvd||fƒ‚dS(Ns^\s+?|\nts {2,}t s%r != %r(R8tsubRA(RMRNR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyteq_ignore_whitespaces cO@sGy|||Žt}Wn|k r0t}nX|sCtdƒ‚dS(Ns#Callable did not raise an exception(RRTRA(t except_clst callable_RRtsuccess((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyt assert_raises's     cO@s‹y#|||Žts"tdƒ‚Wna|k r†}tj|tj|ƒtjƒsltd||fƒ‚tj|ƒjdƒGHnXdS(Ns#Callable did not raise an exceptions%r !~ %ssutf-8(RRAR8tsearchRt text_typetUNICODEtencode(RaR+RbRtkwargste((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_raises_message2s ' tAssertsCompiledSQLc B@s,eZdddddeeedd„ ZRS(c C@s|rtjƒ}n®| r$d}nŸ|dkrEt|ddƒ}n|dkr`tjj}nc|dkr{tjƒ}nH|dkr–tjƒ}n-t|t j ƒrÃt j |ƒj ƒƒ}ni} i} | râ| | dstComparesTablescB@seZed„Zd„ZRS(cC@sÏt|jƒt|jƒks$t‚xMt|j|jƒD]6\}}t|j|jƒ||j|jksut‚t|j|jƒt|j|jƒ|rád}t|j t |j ƒƒsñt||j |j fƒ‚n|j ||ƒt|j t j ƒr"t|j j |j j ƒntd„|jDƒd„|jDƒƒ|jr:t|jtjƒspt‚q:q:Wt|jƒt|jƒks˜t‚x0|jD]%}|jj|jdk s¢t‚q¢WdS(Ns)Type '%s' doesn't correspond to type '%s'cS@sh|]}|jj’qS((tcolumntname(R6tf((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pys «s cS@sh|]}|jj’qS((R R¡(R6R¢((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pys ¬s (tlenR—RAtzipRPR¡t primary_keytnullableRttypetassert_types_basetsqltypestStringtlengtht foreign_keystserver_defaultR t FetchedValuetcolumnsR'(Rttabletreflected_tablet strict_typesR—t reflected_cR+((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_tables_equal–s.$"! $cC@s;|jj|jƒs7td|j|j|jfƒ‚dS(Ns7On column %r, type '%s' doesn't correspond to type '%s'(R§t_compare_type_affinityRAR¡(Rtc1tc2((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR¨·s(RRžRR´R¨(((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyRŸ•s !tAssertsExecutionResultscB@sweZd„Zd„Zd„Zd„Zd d„Zd„Zd„Z d„Z d„Z e j d „ƒZd „ZRS( cG@s.t|ƒ}t|ƒGH|j|||ƒdS(N(R}R‡t assert_list(RRtclass_tobjects((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyt assert_result¿s  cC@sl|jt|ƒt|ƒkdd|jƒx8tdt|ƒƒD]!}|j|||||ƒqCWdS(Ns/result list is not the same size as test list, s for class i(RR£Rtranget assert_row(RRRºtlist_ti((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR¹Äs cC@sé|j|j|kdt|ƒƒx¿|jƒD]±\}}t|tƒr¬t|dtƒr…|jt||ƒ|d|dƒqá|j |dt||ƒ|dƒq0|jt||ƒ|kd|t||ƒ|fƒq0WdS(Nsitem class is not iis'attribute %s value %s does not match %s( Rt __class__R‡titemsRRŠR}R¹RyR¾(RRºtrowobjtdesctkeytvalue((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR¾Îs''c @s:dtfd„ƒY‰tj|ƒ}‡fd†|Dƒ}xCtj‡fd†|ƒD]&}tdt|ƒjˆjfƒqWWt|ƒt|ƒkr¼tdt|ƒt|ƒfƒntƒ‰‡‡fd†}x\|D]T}xK|D]&}|||ƒrë|j |ƒPqëqëWtdˆjt |ƒfƒqÞWt S( sÉ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. t immutabledictcB@seZd„ZRS(cS@s t|ƒS(N(tid(R((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyt__hash__çs(RRžRÉ(((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyRÇæsc@sh|]}ˆ|ƒ’qS(((R6Rj(RÇ(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pys ës c@s t|ˆƒS(N(R(to(tcls(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytîR]s#Unexpected type "%s", expected "%s"s+Unexpected object count "%s", expected "%s"c@sŒx…|jƒD]w\}}t|tƒrhy(ˆjt||ƒ|d|dŒWq„tk rdtSXq t||ˆƒ|kr tSq WtS(Nii(RÂRRŠtassert_unordered_resultRyRARRT(tobjRRÅRÆ(tNOVALUER(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyt _compare_itemýs" s2Expected %s instance with attributes %s not found.( tdictRt IdentitySettitertools_filterfalseRR§RR£R„tremoveR‡RT( RRRËtexpectedtfoundtwrongRÐt expected_itemt found_item((RÏRËRÇRsP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyRÍßs.     cC@s,|dkrddlm}ntj|ƒS(Ni(R(R'R]RRt assert_engine(RR((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytsql_execution_asserters cG@s2|j|ƒ}|ƒ}WdQX|j|Œ|S(N(RÛR(RRRbtrulestasserterR((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_sql_executions c C@s’g}xv|D]n}t|tƒr_tjg|jƒD]\}}tj||ƒ^q5Œ}ntj|Œ}|j|ƒq W|j|||ŒS(N(RRÑRtAllOfRÂt CompiledSQLtappendRÞ( RRRbRÜtnewrulestruletktvtnewrule((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyt assert_sql#s 7cC@s |j||tj|ƒƒdS(N(RÞRtCountStatements(RRRbtcount((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_sql_count1sc C@sÒgt||ƒD]$\}}|j|ƒ||f^q}g}x*|D]"\}}}|j|jƒƒqGWz |ƒSWdxOt||ƒD]>\} \}}}|jdddƒ| jtj|ƒƒq‹WXdS(N( R¤RÛRát __enter__t__exit__R'RRRè( RtdbsRbtcountsRRétrecst asserterstctxRÝ((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_multiple_sql_count6s7 %cg@s.|j|ƒ }dVWdQX|j|ŒdS(N(RÛR(RRRÜRÝ((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_executionEs cC@s|j|tj|ƒƒS(N(RóRRè(RRRé((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_statement_countKsN(RRžR¼R¹R¾RÍR'RÛRÞRçRêRòt contextlibtcontextmanagerRóRô(((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR¸¾s   8     (:t __future__RRõR8R=R]RRRRRFt exclusionsRRRRRR R R R©tengineR R RRRRöRR!R#R$R%RTRRRERIRDR'RORPRQRRRURVRSRWRXRYR\R`RdRkR„RlRŸR¸(((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyts^        ,  *            W)