Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyc


=Nc@sZdZddlmZddlZddlZddlZddlmZmZm	Z	ddlm
Z
mZddlmZddl
mZmZmZddlmZd	Zd
d/dYZdd0d
YZdd1dYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdZeedeeededejfd YZ d!e!fd"YZ"d#ejfd$YZ#d%ejfd&YZ$d'e!fd(YZ%d)efd*YZ&d+e!fd,YZ'd-ejfd.YZ(dS(2s&
Tests for twisted.enterprise.adbapi.
i(tunittestN(tConnectionPooltConnectionLosttsafe(t
ConnectiontTransaction(t_unreleasedVersion(treactortdefert
interfaces(tFailures%
CREATE TABLE simple (
  x integer
)
tADBAPITestBasecBseZdZiZejeddkr3dZndZ	dZ
dZddZdZ
dZdZd	Zd
ZdZdZd
ZdZdZdZdZdZdZdZdZdZdZdZRS(s"Test the asynchronous DB-API code.s5ADB-API requires threads, no way to test without themcCs3|j|jd|j|_|jjdS(sR
        Set up the database and create a connection pool pointing at it.
        t
cp_openfunN(tstartDBtmakePooltopenfuntdbpooltstart(tself((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt
extraSetUp$s
csBjjd}|jfd|jfd|S(NsDROP TABLE simplecs
jjS(N(Rtclose(tres(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt<lambda>/scs
jS(N(tstopDB(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR0s(RtrunOperationtaddCallback(Rtd((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyttearDown-scCst|j|<dS(N(tTruetopenfun_called(Rtconn((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR3scCs6|s|j|jn|j|jj|dS(N(t
failUnlessRthas_key(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytcheckOpenfunCalled6scsjjt}jrt|jj|jj|jj|jj|jfdn|jj	|jj
|jj|jj|jj
|jj|jj|jj|S(Ncs
jS(N(tflushLoggedErrors(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRCs(RRtsimple_table_schemat
test_failuresRt
_testPool_1_1t
_testPool_1_2t
_testPool_1_3t
_testPool_1_4t_testPool_2t_testPool_3t_testPool_4t_testPool_5t_testPool_6t_testPool_7t_testPool_8t_testPool_9(RR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyttestPool<s 	cs8tjjjd}|jfdd|S(Nsselect * from NOTABLEcs
jdS(Nsno exception(tfail(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRPscSsdS(N(tNone(tf((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRQs(Rt
maybeDeferredRtrunQuerytaddCallbacks(RRR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR%Ns
cs8tjjjd}|jfdd|S(Nsdeletexxx from NOTABLEcs
jdS(Nsno exception(R2(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRWscSsdS(N(R3(R4((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRXs(RR5RRR7(RRR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR&Ts
	
cs;tjjjj}|jfdd|S(Ncs
jdS(Nsno exception(R2(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR^scSsdS(N(R3(R4((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR_s(RR5RtrunInteractiontbad_interactionR7(RRR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR'[s

cs;tjjjj}|jfdd|S(Ncs
jdS(Nsno exception(R2(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRescSsdS(N(R3(R4((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRfs(RR5RtrunWithConnectiontbad_withConnectionR7(RRR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR(bs

cs8d}jj|}fd}|j||S(Nsselect count(1) from simplecs2jt|dddkdjdS(NisInteraction not rolled back(RtintR!(trow(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt_checkms$(RR6R(RRtsqlRR>((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR)is

csd}g}x:tjD])}d|}|jjj|qWtj|}fd}|j|fd}|j||S(Nsselect count(1) from simples insert into simple(x) values(%d)csd}jj|}|S(Nsselect x from simple order by x(RR6(RR?R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt_select|scs{jt|jkdxUtjD]D}jt||dkdj||d|kdq/WdS(NsWrong number of rowsisWrong size rowisValues not returned.(Rtlentnum_iterationstrange(trowsti(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR>s
 (RCRBtappendRRRt
gatherResultsR(RRR?tinsertsRERR@R>((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR*ss


cs/jjj}|jfd|S(Ncsj|dS(Ntdone(tassertEqual(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs(RR8tinteractionR(RRR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR+scs/jjj}|jfd|S(Ncsj|dS(NRI(RJ(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs(RR:twithConnectionR(RRR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR,scCs|jj|j}|S(N(RR:tclose_withConnection(RRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR-scsxg}x:tjD])}d|}|jjj|qWtj|dt}fd}|j||S(Ns!select x from simple where x = %dtfireOnOneErrbackcsDx=tjD],}j||ddd|kdqWdS(NiisValue not returned(RCRBR(tresultRE(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR>s(	RCRBRFRR6RtDeferredListRR(RRtdsRER?tdlistR>((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR.s

cCs\g}x:t|jD])}d|}|j|jj|qWtj|dt}|S(Nsdelete from simple where x = %dRN(RCRBRFRRRRPR(RRRQRER?RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR/s
cs8d}jj|}fd}|j||S(Nsselect count(1) from simplecs2jt|dddkdjdS(Nis)Didn't successfully delete table contents(RR<tcheckConnect(R=(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR>s(RR6R(RRR?RR>((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR0s

cCs|jj}|j||j}|jd|jd|j}|jt|d|jt|dd|j|ddd|jd|jd|jt|jd|j|jj	|dS(s/Check the connect/disconnect synchronous calls.sinsert into simple(x) values(1)sselect x from simpleiisdelete from simpleN(
RtconnectR!tcursortexecutetfetchallRJRARt
disconnect(RRtcursR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRSs





cCsm|jdxYt|jD]H}|j}|jt|dkd|j|d|kdqWdS(Nsselect x from simple order by xisWrong size rowisValue not returned.RI(RVRCRBtfetchoneRRA(RttransactionRER=((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRKs
cCs*|jr|jdn|jddS(Nsinsert into simple(x) values(0)sselect * from NOTABLE(tcan_rollbackRV(RR[((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR9s	cCs|j}zm|jdxYt|jD]H}|j}|jt|dkd|j|d|kdq,WWd|jXdS(Nsselect x from simple order by xisWrong size rowisValue not returned.RI(RURVRCRBRZRRAR(RRRYRER=((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRLs
"cCs|jdS(N(R(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRMscCs/|j}z|jdWd|jXdS(Nsselect * from NOTABLE(RURVR(RRRY((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR;sN( t__name__t
__module__t__doc__RR	tIReactorThreadsRR3tskipRRRR!R1R%R&R'R(R)R*R+R,R-R.R/R0RSRKR9RLRMR;(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs6											
					
					
			tReconnectTestBasecBsweZdZejed
d
kr-dZndZdZ	dZ
dZdZdZ
dZd	ZRS(s1Test the asynchronous DB-API code with reconnect.s5ADB-API requires threads, no way to test without themcCsl|jdkr!tjdn|j|jdddtd|j|_|jj|jj	t
S(s
        Skip the test if C{good_sql} is unavailable.  Otherwise, set up the
        database, create a connection pool pointed at it, and set up a simple
        schema in it.
        sno good sql for reconnect testtcp_maxitcp_reconnecttcp_good_sqlN(tgood_sqlR3RtSkipTestR
RRRRRR#(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs

csBjjd}|jfd|jfd|S(NsDROP TABLE simplecs
jjS(N(RR(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRscs
jS(N(R(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs(RRR(RR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRscCsotjd}|j|j|j|j|jsK|j|jn|j|j|j|j	|S(N(
RtsucceedR3Rt_testPool_1R)tearly_reconnectR*R+R,(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR1s	cs8d}jj|}fd}|j||S(Nsselect count(1) from simplecs(jt|dddkddS(NisTable not empty(RR<(R=(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR>!s(RR6R(RRR?RR>((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRis

cCs|jjjdjdS(Ni(RtconnectionstvaluesR(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR)&scs>d}tjjj|}|jfdd|S(Nsselect count(1) from simplecs
jdS(Nsno exception(R2(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR-scSsdS(N(R3(R4((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR.s(RR5RR6R7(RRR?R((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR**s

cs8d}jj|}fd}|j||S(Nsselect count(1) from simplecs(jt|dddkddS(NisTable not empty(RR<(R=(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR>4s(RR6R(RRR?RR>((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR+1s

csNjd}tjjj|}|jfdfd|S(Nsselect * from NOTABLEcs
jdS(Nsno exception(R2(R(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR=scsj|jtS(N(tfailIftcheckR(R4(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR>s(R"RR5RR6R7(RRR?R((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR,9s
N(R]R^R_R	R`RR3RaRRR1RiR)R*R+R,(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRbs				
				tDBTestConnectorcBseZdZd	ZdZdZdZd	Ze	Z
e	Ze	Ze	Z
e	ZejZe	Ze	ZdZdZdZdZdZdZdZRS(
s9A class which knows how to test for the presence of
    and establish a connection to a relational database.

    To enable test cases  which use a central, system database,
    you must create a database named DB_NAME with a user DB_USER
    and password DB_PASS with full access rights to database DB_NAME.
    ttwisted_testi2cCsN|j|_tj|j|jsDtjd|jn|jS(Ns%s: Cannot access db(	tmktemptDB_DIRtostmkdirtcan_connectRRgtTEST_PREFIXR(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytsetUp_s
cCs
tdS(sXReturn true if this database is present on the system
        and can be used in a test.N(tNotImplementedError(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRufscCsdS(s+Take any steps needed to bring database up.N((R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR
kscCsdS(sBring database down, if needed.N((R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRoscKs8|j\}}|j}|j|t||S(s;Create a connection pool with additional keyword arguments.(tgetPoolArgstcopytupdateR(Rtnewkwtargstkw((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRss
cCs
tdS(sReturn a tuple (args, kw) of list and keyword arguments
        that need to be passed to ConnectionPool to create a connection
        to this database.N(Rx(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRyzsN(R]R^R_R3RvtDB_NAMEtDB_USERtDB_PASSRrRtnulls_okttrailing_spaces_okR\R$tescape_slashesRRfRjt	can_clearRBRwRuR
RRRy(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRoBs*						tGadflyConnectorcBsGeZdZeZeZeZdZdZdZ	dZ
dZRS(tGadflysselect * from simple where 1=0icCs@yddl}WntSXt|dds<|j|_ntS(NiRT(tgadflytFalsetgetattrR3RTR(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRuscCs_ddl}|j}|j|j|j|j}|jd|j|jdS(Niscreate table x (x integer)(RtstartupRRrRURVtcommitR(RRRRU((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR
s

cCs,d|j|jf}idd6}||fS(NRiRc(RRr(RR}R~((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRys
(R]R^RvRRR\RRfRBRuR
Ry(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs		tSQLiteConnectorcBs5eZdZeZdZdZdZdZRS(tSQLiteicCsyddl}WntSXtS(Ni(tsqliteRR(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRus
cCsJtjj|j|j|_tjj|jrFtj|jndS(N(RstpathtjoinRrRtdatabasetexiststunlink(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR
scCs'd}i|jd6dd6}||fS(NRRiRc(ssqlite(R(RR}R~((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRys(	R]R^RvRRRBRuR
Ry(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs		tPyPgSQLConnectorcBs eZdZdZdZRS(tPyPgSQLcCsgyddlm}WntSXy9|jd|jd|jd|j}|jtSWntSXdS(Ni(tPgSQLRtusertpassword(	tpyPgSQLRRRTRRRRR(RRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRus
cCs;d}i|jd6|jd6|jd6dd6}||fS(Ns
pyPgSQL.PgSQLRRRitcp_min(s
pyPgSQL.PgSQL(RRR(RR}R~((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRys(R]R^RvRuRy(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs	tPsycopgConnectorcBs eZdZdZdZRS(tPsycopgcCscyddl}WntSXy9|jd|jd|jd|j}|jtSWntSXdS(NiRRR(tpsycopgRRTRRRRR(RRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRus
cCs;d}i|jd6|jd6|jd6dd6}||fS(NRRRRiR(spsycopg(RRR(RR}R~((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRys(R]R^RvRuRy(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs	tMySQLConnectorcBs2eZdZeZeZeZdZdZRS(tMySQLcCscyddl}WntSXy9|jd|jd|jd|j}|jtSWntSXdS(NitdbRtpasswd(tMySQLdbRRTRRRRR(RRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRus
cCs4d}i|jd6|jd6|jd6}||fS(NRRRR(sMySQLdb(RRR(RR}R~((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRys$(	R]R^RvRRR\RjRuRy(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs	tFirebirdConnectorcBsPeZdZeZeZdZeZdZ	dZ
dZdZdZ
RS(tFirebirdicCsFyddl}WntSXy|j|jtSWntSXdS(Ni(tkinterbasdbRR
RR(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRus

cCsddl}tjj|jtj|_tj|jtj	tj
tjd}||j|j|j
f;}|j|}|jdS(Nis,create database "%s" user "%s" password "%s"(RRsRRRrRoRtchmodtstattS_IRWXUtS_IRWXGtS_IRWXORRtcreate_databaseR(RRR?R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR
s$cCs;d}i|jd6dd6|jd6|jd6}||fS(NRRs	127.0.0.1thostRR(skinterbasdb(RRR(RR}R~((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRysc	CsGddl}|jd|jddd|jd|j}|jdS(NiRRs	127.0.0.1RR(RRTRRRt
drop_database(RRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs
N(R]R^RvRR$RR3RfRRBRuR
RyR(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs		
	cCshttttttg}xI|D]A}|j|}tj|||t	j
f|j}|||<qWdS(sQ
    Make a test case for every db connector which can connect.

    @param base: Base class for test case. Additional base classes
                 will be a DBConnector subclass and unittest.TestCase
    @param suffix: A suffix used to create test case names. Prefixes
                   are defined in the DBConnector subclasses.
    N(RRRRRRRvttypest	ClassTypeRtTestCaset__dict__(tbasetsuffixtglobalst
connectorst	connclasstnametklass((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytmakeSQLTests"s		

tADBAPITestCasetReconnectTestCasetDeprecationTestCasecBseZdZdZRS(s8
    Test deprecations in twisted.enterprise.adbapi
    cCs)|jttd}|j|ddS(sF
        Test deprecation of twisted.enterprise.adbapi.safe()
        stest'stest''N(tcallDeprecatedRRRJ(RRO((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt	test_safeBs	(R]R^R_R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR=stFakePoolcBs5eZdZeZeZdZdZdZRS(s
    A fake L{ConnectionPool} for tests.

    @ivar connectionFactory: factory for making connections returned by the
        C{connect} method.
    @type connectionFactory: any callable
    cCs
||_dS(N(tconnectionFactory(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt__init__YscCs
|jS(sB
        Return an instance of C{self.connectionFactory}.
        (R(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRT]scCsdS(s
        Do nothing.
        N((Rt
connection((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRXds(	R]R^R_Rt	reconnecttnoisyRRTRX(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRNs		tConnectionTestCasecBseZdZdZRS(s,
    Tests for the L{Connection} class.
    cCsdtfdY}t|}t|}|jt|j|jt}|jt	|d|j|dj
jdddS(s|
        If an error happens during rollback, L{ConnectionLost} is raised but
        the original error is logged.
        tConnectionRollbackRaisecBseZdZRS(cSstddS(Nsproblem!(tRuntimeError(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytrollbackvs(R]R^R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRusiisproblem!N(tobjectRRtassertRaisesRRR"RRJRAtvalueR}(RRtpoolRterrors((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyttest_rollbackErrorLoggedps(R]R^R_R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRkstTransactionTestCasecBseZdZdZRS(s-
    Tests for the L{Transaction} class.
    cCsdtfdY}td}t||}|j|jt}|jt|d|j|dj	j
dddS(s
        If the cursor creation raises an error in L{Transaction.reopen}, it
        reconnects but log the error occurred.
        tConnectionCursorRaisecBs eZdZdZdZRS(icSsdS(N((R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRscSs1|jdkr-|jd7_tdndS(Niisproblem!(tcountR(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRUs(R]R^RRRU(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs	iisproblem!N(RRR3RtreopenR"RRJRARR}(RRRR[R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyttest_reopenLogErrorIfReconnects
(R]R^R_R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRst
NonThreadPoolcBseZdZRS(cOsOt}y|||}Wn"tk
r=}t}t}nX|||dS(N(Rt	ExceptionRR
(RtonResultR4taR~tsuccessROte((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytcallInThreadWithCallbacks
(R]R^R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRstDummyConnectionPoolcBs eZdZeZdZRS(s'
    A testable L{ConnectionPool};
    cCs
t|_dS(s*
        Don't forward init call.
        N(R(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs(R]R^R_Rt
threadpoolR(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs	tEventReactorcBs2eZdZdZdZdZdZRS(s
    Partial L{IReactorCore} implementation with simple event-related
    methods.

    @ivar _running: A C{bool} indicating whether the reactor is pretending
        to have been started already or not.

    @ivar triggers: A C{list} of pending system event triggers.
    cCs||_g|_dS(N(t_runningttriggers(Rtrunning((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs	cCs*|jr|n|jdd|SdS(NtafterR(RtaddSystemEventTrigger(Rtfunction((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytcallWhenRunnings	
cCs#|||f}|jj||S(N(RRF(Rtphaseteventttriggerthandle((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRscCs|jj|dS(N(Rtremove(RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytremoveSystemEventTriggers(R]R^R_RRRR(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs
				tConnectionPoolTestCasecBs;eZdZdZdZdZdZdZRS(s+
    Unit tests for L{ConnectionPool}.
    csrdtfdY}d}t}||_|j|}j|t}fd}|j||S(s
        If rollback fails, L{ConnectionPool.runWithConnection} raises the
        original exception and log the error of the rollback.
        RcBseZdZdZRS(cSsdS(N((RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRscSstddS(Nsproblem!(R(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs(R]R^RR(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs	cSstddS(Ntfoo(t
ValueError(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytraisingFunctionscsGjt}jt|dj|djjdddS(Niisproblem!(R"RRJRARR}(tignoredR(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pytcbFaileds(RRRR:t
assertFailureRR(RRRRRR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt(test_runWithConnectionRaiseOriginalErrors			
cCsvdtfdY}t}|j||jt}|jt|d|j|djjdddS(s;
        L{ConnectionPool._close} logs exceptions.
        tConnectionCloseRaisecBseZdZRS(cSstddS(Nsproblem!(R(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs(R]R^R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRsiisproblem!N(	RRt_closeR"RRJRARR}(RRRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyttest_closeLogErrors	csdtfdY}dtfdY}d}t}||_||_|j|}j|t}fd}|j||S(s
        If rollback fails, L{ConnectionPool.runInteraction} raises the
        original exception and log the error of the rollback.
        RcBseZdZdZRS(cSsdS(N((RR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRscSstddS(Nsproblem!(R(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs(R]R^RR(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs	tDummyTransactioncBseZdZRS(cSsdS(N((RRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs(R]R^R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRscSstddS(NR(R(R[((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRscsGjt}jt|dj|djjdddS(Niisproblem!(R"RRJRARR}(RR(R(s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyR$s(RRRttransactionFactoryR8RRR(RRRRRRR((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt)test_runWithInteractionRaiseOriginalErrors				
cCs^tt}tdd|}|j|jdd|jfg|j|j|jdS(s
        If L{ConnectionPool.close} is called without L{ConnectionPool.start}
        having been called, the pool's startup event is cancelled.
        stwisted.test.test_adbapit
cp_reactorRRN(RRRRJRt_startRtassertFalse(RRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyttest_unstartedClose,s
"
cCs^tt}tdd|}|j|jdd|jfg|j|j|jdS(s
        If L{ConnectionPool.close} is called after it has been started, but
        not by its shutdown trigger, the shutdown trigger is cancelled.
        stwisted.test.test_adbapiRtduringtshutdownN(RRRRJRt
finalCloseRR(RRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyttest_startedClose:s
"
(R]R^R_RRRRR(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyRs			!	(((()R_t
twisted.trialRRsRRttwisted.enterprise.adbapiRRRRRRttwisted.internetRRR	ttwisted.python.failureR
R#RRbRoRRRRRRRRRRRRRRRRRR(((s</usr/lib/python2.7/dist-packages/twisted/test/test_adbapi.pyt<module>s:I>!,	!