%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyc

�
��4]c@@s�ddlmZddlZddlZddlZddlmZddlmZddlmZddlm	Z
ddlmZdd	l	m
Z
d
dlmZd
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�tddj�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_warn�s 


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	<genexpr>�s(
tretcompiletItStsettwarningstwarnRtpatchRtpy3ktAssertionErrortjoin(R/RR2Rtpy2konlyR+R4((R/R0R1R2R3sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR�s2	cC@st�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�td��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.pytstartswith_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�tj|�j
��}ni}i}
|r�||d<n|dk	rt|�|d<n|
rt|
d<nt|tj�rJ|j�}t|j_|j}nUt|tjj�r�tjj|d��&}|j�|jdd	d}WdQXn|
r�|
|d
<n|jd||�}tt|di��}t	jr%|jd
�j dd�}dt	j!|�|jd
�GHndt	j!|�jd
�|GHt"j#ddt	j!|��}t$||d|||f�|dk	r�t$|j%|�|�n|dk	r�|j%|�}t$t&g|j'D]}||^q��|�n|dk	rt$|j(|�ndS(Nt__dialect__Rtdefault_enhancedtschema_translate_maptcolumn_keyst
literal_bindst
_execute_stmtiitcompile_kwargstdialecttparamssutf-8tasciitignores

SQL String:
s[\n\t]R]s%r != %r on dialect %r()RtDefaultDialectR'tgetattrRRRttStrCompileDialectRRRR
tURLtget_dialecttlistRTRtQueryt_compile_contextt	statementt
use_labelstpersistencetBulkUDRR?tobjecttexec_t
mock_callsR9treprR@RhtdecodeRfR8R_RPtconstruct_paramsttupletpositiontuptprefetch(tselftclausetresultRutcheckparamsRttcheckpositionaltcheck_prefetchtuse_default_dialecttallow_dialect_selectRqRoRRstcontextt	stmt_mocktct	param_strtcctptx((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_compile?s`	



	0N(t__name__t
__module__R'RR�(((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyRl>stComparesTablescB@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	tj�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	<setcomp>�s	cS@sh|]}|jj�qS((R�R�(R6R�((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pys	<setcomp>�s	(tlenR�RAtzipRPR�tprimary_keytnullableRttypetassert_types_basetsqltypestStringtlengthtforeign_keystserver_defaultR
tFetchedValuetcolumnsR'(R�ttabletreflected_tabletstrict_typesR�treflected_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�(R�tc1tc2((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR��s(R�R�RR�R�(((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyR��s!tAssertsExecutionResultscB@sweZd�Zd�Zd�Zd�Zdd�Zd�Zd�Z	d�Z
d�Zej
d	��Zd
�ZRS(cG@s.t|�}t|�GH|j|||�dS(N(R}R�tassert_list(R�R�tclass_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�R�tranget
assert_row(R�R�R�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�(R�R�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�WtS(	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(R�R�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	<setcomp>�s	c@s
t|��S(N(R(to(tcls(sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pyt<lambda>�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.(tdictRtIdentitySettitertools_filterfalseRR�R�R�R�tremoveR�RT(	R�R�R�texpectedtfoundtwrongR�t
expected_itemt
found_item((R�R�R�R�sP/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(R�R((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytsql_execution_asserterscG@s2|j|��}|�}WdQX|j|�|S(N(R�R(R�RRbtrulestasserterR�((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�tCompiledSQLtappendR�(	R�RRbR�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(R�RRbtcount((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�(
R�tdbsRbtcountsRR�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(R�RR�R�((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_executionEscC@s|j|tj|��S(N(R�RR�(R�RR�((sP/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/assertions.pytassert_statement_countKsN(R�R�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
RR�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.pyt<module>s^					,		*			W)

Zerion Mini Shell 1.0