HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_adbapi.cpython-38.pyc
U

��W[$f�@s�dZddlmZddlZddlZddlmZmZddlmZm	Z	ddl
mZmZm
Z
ddlmZddlmZd	ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�Zeede��eede��Gd d!�d!e�ZGd"d#�d#ej �Z!Gd$d%�d%ej �Z"Gd&d'�d'e�Z#Gd(d)�d)e�Z$Gd*d+�d+e�Z%Gd,d-�d-ej �Z&dS).z&
Tests for twisted.enterprise.adbapi.
�)�unittestN)�ConnectionPool�ConnectionLost)�
Connection�Transaction)�reactor�defer�
interfaces)�Failure��
requireModulez%
CREATE TABLE simple (
  x integer
)
c@s�eZdZdZiZe�ed�dkr$dZdd�Z	dd�Z
dd	�Zd2d
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdS)3�ADBAPITestBasez,
    Test the asynchronous DB-API code.
    N�5ADB-API requires threads, no way to test without themcCs&|��|j|jd�|_|j��dS)zR
        Set up the database and create a connection pool pointing at it.
        )Z
cp_openfunN)�startDB�makePool�openfun�dbpool�start��self�r�:/usr/lib/python3/dist-packages/twisted/test/test_adbapi.py�
extraSetUp%szADBAPITestBase.extraSetUpcs4�j�d�}|��fdd��|��fdd��|S)N�DROP TABLE simplecs
�j��S�N�r�close��resrrr�<lambda>0�z)ADBAPITestBase.tearDown.<locals>.<lambda>cs���Sr��stopDBrrrrr1r �r�runOperation�addCallback�r�drrr�tearDown.szADBAPITestBase.tearDowncCsd|j|<dS)NT)�openfun_called�r�connrrrr5szADBAPITestBase.openfuncCs$|s|�|j�n|�||j�dSr)�
assertTruer)ZassertInr*rrr�checkOpenfunCalled9sz!ADBAPITestBase.checkOpenfunCalledcs��j�t�}�jrT|��j�|��j�|��j�|��j�|��fdd��|��j	�|��j
�|��j�|��j�|��j
�|��j�|��j�|��j�|S)Ncs���Sr)�flushLoggedErrorsrrrrrGr z*ADBAPITestBase.test_pool.<locals>.<lambda>)rr$�simple_table_schema�
test_failuresr%�
_testPool_1_1�
_testPool_1_2�
_testPool_1_3�
_testPool_1_4�_testPool_2�_testPool_3�_testPool_4�_testPool_5�_testPool_6�_testPool_7�_testPool_8�_testPool_9r&rrr�	test_pool@s zADBAPITestBase.test_poolcs,t��jjd�}|��fdd�dd��|S)N�select * from NOTABLEcs
��d�S�Nzno exception�ZfailrrrrrUr z.ADBAPITestBase._testPool_1_1.<locals>.<lambda>cSsdSrr��frrrrVr �r�
maybeDeferredr�runQuery�addCallbacks�rrr'rrrr1Ss
�zADBAPITestBase._testPool_1_1cs,t��jjd�}|��fdd�dd��|S)Nzdeletexxx from NOTABLEcs
��d�Sr?r@rrrrr]r z.ADBAPITestBase._testPool_1_2.<locals>.<lambda>cSsdSrrrArrrr^r )rrDrr$rFrGrrrr2Zs
��zADBAPITestBase._testPool_1_2cs.t��jj�j�}|��fdd�dd��|S)Ncs
��d�Sr?r@rrrrrer z.ADBAPITestBase._testPool_1_3.<locals>.<lambda>cSsdSrrrArrrrfr )rrDr�runInteraction�bad_interactionrFrGrrrr3bs
��zADBAPITestBase._testPool_1_3cs.t��jj�j�}|��fdd�dd��|S)Ncs
��d�Sr?r@rrrrrmr z.ADBAPITestBase._testPool_1_4.<locals>.<lambda>cSsdSrrrArrrrnr )rrDr�runWithConnection�bad_withConnectionrFrGrrrr4js
��zADBAPITestBase._testPool_1_4cs*d}�j�|�}�fdd�}|�|�|S)N�select count(1) from simplecs(��t|dd�dkd����dS)NrzInteraction not rolled back)r,�intr-��rowrrr�_checkvsz*ADBAPITestBase._testPool_2.<locals>._check�rrEr%�rr�sqlr'rPrrrr5rs

zADBAPITestBase._testPool_2csld}g}t�j�D]}d|}|��j�|��qt�|�}�fdd�}|�|��fdd�}|�|�|S)NrLz insert into simple(x) values(%d)csd}�j�|�}|S)N�select x from simple order by x)rrE)rrSr'rrr�_select�sz+ADBAPITestBase._testPool_3.<locals>._selectcsZ��t|��jkd�t�j�D]4}��t||�dkd���||d|kd�q dS)NzWrong number of rows��Wrong size rowrzValues not returned.)r,�len�num_iterations�range)Zrows�irrrrP�s�z*ADBAPITestBase._testPool_3.<locals>._check)rZrY�appendrr$rZ
gatherResultsr%)rrrSZinsertsr[r'rUrPrrrr6}s


zADBAPITestBase._testPool_3cs$�j��j�}|��fdd��|S)Ncs��|d�S�N�done��assertEqualrrrrr�r z,ADBAPITestBase._testPool_4.<locals>.<lambda>)rrH�interactionr%rGrrrr7�szADBAPITestBase._testPool_4cs$�j��j�}|��fdd��|S)Ncs��|d�Sr]r_rrrrr�r z,ADBAPITestBase._testPool_5.<locals>.<lambda>)rrJ�withConnectionr%rGrrrr8�szADBAPITestBase._testPool_5cCs|j�|j�}|Sr)rrJ�close_withConnectionrGrrrr9�szADBAPITestBase._testPool_6csVg}t�j�D]}d|}|��j�|��qtj|dd�}�fdd�}|�|�|S)Nz!select x from simple where x = %dT�ZfireOnOneErrbackcs4t�j�D]$}��||ddd|kd�q
dS)NrVrzValue not returned)rZrYr,)�resultr[rrrrP�sz*ADBAPITestBase._testPool_7.<locals>._check)rZrYr\rrEr�DeferredListr%)rr�dsr[rS�dlistrPrrrr:�s
zADBAPITestBase._testPool_7cCs@g}t|j�D]}d|}|�|j�|��qtj|dd�}|S)Nzdelete from simple where x = %dTrd)rZrYr\rr$rrf)rrrgr[rSrhrrrr;�szADBAPITestBase._testPool_8cs*d}�j�|�}�fdd�}|�|�|S)NrLcs(��t|dd�dkd����dS)Nrz)Didn't successfully delete table contents)r,rM�checkConnectrNrrrrP�s�z*ADBAPITestBase._testPool_9.<locals>._checkrQrRrrrr<�s

zADBAPITestBase._testPool_9cCs�|j��}|�|�|��}|�d�|�d�|��}|�t|�d�|�t|d�d�|�|ddd�|�d�|�d�|�t|���d�|��|j�	|�dS)z/Check the connect/disconnect synchronous calls.zinsert into simple(x) values(1)zselect x from simplerVrzdelete from simpleN)
r�connectr-�cursor�executeZfetchallr`rXr�
disconnect)rr+�cursrrrrri�s





zADBAPITestBase.checkConnectcCs^|�d�t|j�D]4}|��}|�t|�dkd�|�|d|kd�q|�|��d�dS)NrTrVrWr�Value not returned.z
Too many rowsr^)rlrZrY�fetchoner,rXZassertIsNone)r�transactionr[rOrrrra�s
zADBAPITestBase.interactioncCs|jr|�d�|�d�dS)Nzinsert into simple(x) values(0)r>)�can_rollbackrl)rrqrrrrI�s
zADBAPITestBase.bad_interactioncCsf|��}zN|�d�t|j�D]4}|��}|�t|�dkd�|�|d|kd�qW5|��XdS)NrTrVrWrror^)rkrrlrZrYrpr,rX)rr+rnr[rOrrrrb�s

zADBAPITestBase.withConnectioncCs|��dSr)rr*rrrrcsz#ADBAPITestBase.close_withConnectioncCs&|��}z|�d�W5|��XdS)Nr>)rkrrl)rr+rnrrrrKsz!ADBAPITestBase.bad_withConnection)N) �__name__�
__module__�__qualname__�__doc__r)r	�IReactorThreadsr�skiprr(rr-r=r1r2r3r4r5r6r7r8r9r:r;r<rirarIrbrcrKrrrrr
s6	



r
c@sdeZdZdZe�ed�dkr dZdd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�ZdS)�ReconnectTestBasez;
    Test the asynchronous DB-API code with reconnect.
    NrcCsF|jdkrt�d��|��|jdd|jd�|_|j��|j�t�S)z�
        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.
        Nzno good sql for reconnect testrVT)�cp_maxZcp_reconnectZcp_good_sql)	�good_sqlr�SkipTestrrrrr$r/rrrrrs

�
zReconnectTestBase.extraSetUpcs4�j�d�}|��fdd��|��fdd��|S)Nrcs
�j��Srrrrrrr'r z,ReconnectTestBase.tearDown.<locals>.<lambda>cs���Srr!rrrrr(r r#r&rrrr(%szReconnectTestBase.tearDowncCsPt�d�}|�|j�|�|j�|js4|�|j�|�|j�|�|j�|Sr)	rZsucceedr%�_testPool_1r5�early_reconnectr6r7r8r&rrrr=,s
zReconnectTestBase.test_poolcs*d}�j�|�}�fdd�}|�|�|S)NrLcs ��t|dd�dkd�dS�NrzTable not empty�r,rMrNrrrrP:sz-ReconnectTestBase._testPool_1.<locals>._checkrQrRrrrr}7s

zReconnectTestBase._testPool_1cCst|jj���d��dS)Nr)�listrZconnections�valuesr)rrrrrr5@szReconnectTestBase._testPool_2cs0d}t��jj|�}|��fdd�dd��|S)NrLcs
��d�Sr?r@rrrrrHr z/ReconnectTestBase._testPool_3.<locals>.<lambda>cSsdSrrrArrrrIr rC�rrrSr'rrrr6Es�zReconnectTestBase._testPool_3cs*d}�j�|�}�fdd�}|�|�|S)NrLcs ��t|dd�dkd�dSrr�rNrrrrPPsz-ReconnectTestBase._testPool_4.<locals>._checkrQrRrrrr7Ms

zReconnectTestBase._testPool_4cs<���d}t��jj|�}|��fdd��fdd��|S)Nr>cs
��d�Sr?r@rrrrrZr z/ReconnectTestBase._testPool_5.<locals>.<lambda>cs��|�t��Sr)�assertFalseZcheckrrArrrr[r )r.rrDrrErFr�rrrr8Vs
�zReconnectTestBase._testPool_5)rsrtrurvr	rwrrxrr(r=r}r5r6r7r8rrrrry
s		ryc@szeZdZdZdZdZdZdZdZdZ	dZ
dZdZdZ
ejZdZdZdZdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)�DBTestConnectora>
    A 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.
    NZtwisted_testT�2cCs6|��|_t�|j�|��s.t�d|j��|��S)Nz%s: Cannot access db)	Zmktemp�DB_DIR�os�mkdir�can_connectrr|�TEST_PREFIXrrrrr�setUp}s

zDBTestConnector.setUpcCs
t��dS)zXReturn true if this database is present on the system
        and can be used in a test.N��NotImplementedErrorrrrrr��szDBTestConnector.can_connectcCsdS)z+Take any steps needed to bring database up.Nrrrrrr�szDBTestConnector.startDBcCsdS)zBring database down, if needed.Nrrrrrr"�szDBTestConnector.stopDBcKs(|��\}}|��}|�|�t||�S)z;Create a connection pool with additional keyword arguments.)�getPoolArgs�copy�updater)rZnewkw�args�kwrrrr�s
zDBTestConnector.makePoolcCs
t��dS)z�Return a tuple (args, kw) of list and keyword arguments
        that need to be passed to ConnectionPool to create a connection
        to this database.Nr�rrrrr��szDBTestConnector.getPoolArgs)rsrtrurvr��DB_NAME�DB_USER�DB_PASSr�Znulls_ok�trailing_spaces_okrrr0�escape_slashesrr{r~�	can_clearrYr�r�rr"rr�rrrrr�`s*r�c@s4eZdZdZdZdZdZdd�Zdd�Zd	d
�Z	dS)�SQLite3ConnectorzB
    Connector that uses the stdlib SQLite3 database support.
    ZSQLite3FrVcCstd�dkrdSdSdS)N�sqlite3FTrrrrrr��szSQLite3Connector.can_connectcCs2tj�|j|j�|_tj�|j�r.t�|j�dSr�r��path�joinr�r��database�exists�unlinkrrrrr�szSQLite3Connector.startDBcCsd}|jddd�}||fS)N)r�rVF�r�rzZcheck_same_thread�r��rr�r�rrrr��s�zSQLite3Connector.getPoolArgsN�
rsrtrurvr�r�rYr�rr�rrrrr��sr�c@s4eZdZdZdZdZdZdd�Zdd�Zd	d
�Z	dS)�PySQLite2ConnectorzA
    Connector that uses pysqlite's SQLite database support.
    Z	pysqlite2FrVcCstd�dkrdSdSdS)N�pysqlite2.dbapi2FTrrrrrr��szPySQLite2Connector.can_connectcCs2tj�|j|j�|_tj�|j�r.t�|j�dSrr�rrrrr�szPySQLite2Connector.startDBcCsd}|jddd�}||fS)N)r�rVFr�r�r�rrrr��s�zPySQLite2Connector.getPoolArgsNr�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�PyPgSQLConnectorZPyPgSQLcCsXzddlm}WnYdSXz$|j|j|j|jd�}|��WdSYdSXdS)Nr)�PgSQLF�r��user�passwordT)ZpyPgSQLr�rjr�r�r�r)rr�r+rrrr��s�zPyPgSQLConnector.can_connectcCs d}|j|j|jdd�}||fS)N)z
pyPgSQL.PgSQLr�r�r�r�Zcp_min�r�r�r�r�rrrr��s�zPyPgSQLConnector.getPoolArgsN�rsrtrur�r�r�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�PsycopgConnectorZPsycopgcCsTzddl}WnYdSXz$|j|j|j|jd�}|��WdSYdSXdS)NrFr�T)�psycopgrjr�r�r�r)rr�r+rrrr��s�zPsycopgConnector.can_connectcCs d}|j|j|jdd�}||fS)N)r�rr�r�r�rrrr�s�zPsycopgConnector.getPoolArgsNr�rrrrr��sr�c@s,eZdZdZdZdZdZdd�Zdd�ZdS)�MySQLConnectorZMySQLFcCsTzddl}WnYdSXz$|j|j|j|jd�}|��WdSYdSXdS)NrF�Zdbr�ZpasswdT)�MySQLdbrjr�r�r�r)rr�r+rrrr�s�zMySQLConnector.can_connectcCsd}|j|j|jd�}||fS)N)r�r�r�r�rrrr�"szMySQLConnector.getPoolArgsN)	rsrtrur�r�rrr~r�r�rrrrr�sr�c@sDeZdZdZdZdZdZdZdZdd�Z	dd�Z
d	d
�Zdd�ZdS)
�FirebirdConnectorZFirebirdFN�cCs:td�dkrdSz|��|��WdSYdSXdS)N�kinterbasdbFT)rrr"rrrrr�4szFirebirdConnector.can_connectcCsfddl}tj�|jtj�|_t�|jtj	tj
tj�d}||j|j|j
f;}|�|�}|��dS)Nrz,create database "%s" user "%s" password "%s")r�r�r�r�r�r�r��chmod�stat�S_IRWXU�S_IRWXG�S_IRWXOr�r�Zcreate_databaser)rr�rSr+rrrr?s
zFirebirdConnector.startDBcCs d}|jd|j|jd�}||fS)N)r��	127.0.0.1�r�Zhostr�r�r�r�rrrr�Is�zFirebirdConnector.getPoolArgscCs,ddl}|j|jd|j|jd�}|��dS)Nrr�r�)r�rjr�r�r�Z
drop_database)rr�r+rrrr"Ps�zFirebirdConnector.stopDB)
rsrtrur�r0r�r{r�rYr�rr�r"rrrrr�)s
r�cs�ttttttg}i}|D]`��j|}G�fdd�d�|tj�}||_	t
�d�rpd��j�
�dd�|g�|_|||<q|�|�dS)aQ
    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.
    cseZdZ�jZdS)zmakeSQLTests.<locals>.testcaseN)rsrtrur�Z	connclassrr�testcasehsr�ru�.r���N)r�r�r�r�r�r�r�r�TestCasers�hasattrr�ru�splitr�)�base�suffix�globalsZ
connectorsZtests�namer�rr�r�makeSQLTestsYs 	�

�
r�ZADBAPITestsZReconnectTestsc@s0eZdZdZdZdZdd�Zdd�Zdd�Zd	S)
�FakePoolz�
    A fake L{ConnectionPool} for tests.

    @ivar connectionFactory: factory for making connections returned by the
        C{connect} method.
    @type connectionFactory: any callable
    TcCs
||_dSr��connectionFactory)rr�rrr�__init__�szFakePool.__init__cCs|��S)zB
        Return an instance of C{self.connectionFactory}.
        r�rrrrrj�szFakePool.connectcCsdS)z
        Do nothing.
        Nr)r�
connectionrrrrm�szFakePool.disconnectN)	rsrtrurv�	reconnectZnoisyr�rjrmrrrrr�sr�c@seZdZdZdd�ZdS)�ConnectionTestsz,
    Tests for the L{Connection} class.
    cCsdGdd�dt�}t|�}t|�}|�t|j�|�t�}|�t	|�d�|�|dj
jdd�dS)z|
        If an error happens during rollback, L{ConnectionLost} is raised but
        the original error is logged.
        c@seZdZdd�ZdS)zIConnectionTests.test_rollbackErrorLogged.<locals>.ConnectionRollbackRaisecSstd��dS�N�problem!��RuntimeErrorrrrr�rollback�szRConnectionTests.test_rollbackErrorLogged.<locals>.ConnectionRollbackRaise.rollbackN)rsrtrur�rrrr�ConnectionRollbackRaise�sr�rVrr�N)�objectr�rZassertRaisesrr�r.r�r`rX�valuer�)rr��poolr��errorsrrr�test_rollbackErrorLogged�s
z(ConnectionTests.test_rollbackErrorLoggedN)rsrtrurvr�rrrrr��sr�c@seZdZdZdd�ZdS)�TransactionTestsz-
    Tests for the L{Transaction} class.
    cCsbGdd�dt�}td�}t||��}|��|�t�}|�t|�d�|�|djj	dd�dS)z�
        If the cursor creation raises an error in L{Transaction.reopen}, it
        reconnects but log the error occurred.
        c@s eZdZdZdd�Zdd�ZdS)zNTransactionTests.test_reopenLogErrorIfReconnect.<locals>.ConnectionCursorRaisercSsdSrrrrrrr��szXTransactionTests.test_reopenLogErrorIfReconnect.<locals>.ConnectionCursorRaise.reconnectcSs$|jdkr |jd7_td��dS)NrrVr�)�countr�rrrrrk�s
zUTransactionTests.test_reopenLogErrorIfReconnect.<locals>.ConnectionCursorRaise.cursorN)rsrtrur�r�rkrrrr�ConnectionCursorRaise�sr�NrVrr�)
r�r�rZreopenr.r�r`rXr�r�)rr�r�rqr�rrr�test_reopenLogErrorIfReconnect�s
z/TransactionTests.test_reopenLogErrorIfReconnectN)rsrtrurvr�rrrrr��sr�c@seZdZdd�ZdS)�
NonThreadPoolcOs@d}z|||�}Wntk
r0d}t�}YnX|||�dS)NTF)�	Exceptionr
)rZonResultrB�ar�Zsuccessrerrr�callInThreadWithCallback�sz&NonThreadPool.callInThreadWithCallbackN)rsrtrur�rrrrr��sr�c@seZdZdZe�Zdd�ZdS)�DummyConnectionPoolz'
    A testable L{ConnectionPool};
    cCs
t|_dS)z*
        Don't forward init call.
        N)rZ_reactorrrrrr��szDummyConnectionPool.__init__N)rsrtrurvr�Z
threadpoolr�rrrrr��sr�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�EventReactora
    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|_dSr)�_running�triggers)r�runningrrrr��szEventReactor.__init__cCs |jr|�n|�dd|�SdS)N�after�startup)r��addSystemEventTrigger)rZfunctionrrr�callWhenRunning�szEventReactor.callWhenRunningcCs|||f}|j�|�|Sr)r�r\)rZphaseZeventZtrigger�handlerrrr�s
z"EventReactor.addSystemEventTriggercCs|j�|�dSr)r��remove)rr�rrr�removeSystemEventTriggersz%EventReactor.removeSystemEventTriggerN)rsrtrurvr�r�r�r�rrrrr��s
	r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ConnectionPoolTestsz+
    Unit tests for L{ConnectionPool}.
    csTGdd�dt�}dd�}t�}||_|�|�}��|t�}�fdd�}|�|�|S)z�
        If rollback fails, L{ConnectionPool.runWithConnection} raises the
        original exception and log the error of the rollback.
        c@seZdZdd�Zdd�ZdS)z]ConnectionPoolTests.test_runWithConnectionRaiseOriginalError.<locals>.ConnectionRollbackRaisecSsdSrr�rr�rrrr�szfConnectionPoolTests.test_runWithConnectionRaiseOriginalError.<locals>.ConnectionRollbackRaise.__init__cSstd��dSr�r�rrrrr�szfConnectionPoolTests.test_runWithConnectionRaiseOriginalError.<locals>.ConnectionRollbackRaise.rollbackN�rsrtrur�r�rrrrr�sr�cSstd��dS�NZfoo��
ValueError)r�rrr�raisingFunctionszUConnectionPoolTests.test_runWithConnectionRaiseOriginalError.<locals>.raisingFunctioncs6��t�}��t|�d���|djjdd�dS�NrVrr��r.r�r`rXr�r��Zignoredr�rrr�cbFailed$s
zNConnectionPoolTests.test_runWithConnectionRaiseOriginalError.<locals>.cbFailed)r�r�r�rJ�
assertFailurer�r%)rr�r�r�r'r�rrr�(test_runWithConnectionRaiseOriginalErrors

z<ConnectionPoolTests.test_runWithConnectionRaiseOriginalErrorcCsXGdd�dt�}t�}|�|��|�t�}|�t|�d�|�|djjdd�dS)z;
        L{ConnectionPool._close} logs exceptions.
        c@seZdZdd�ZdS)zDConnectionPoolTests.test_closeLogError.<locals>.ConnectionCloseRaisecSstd��dSr�r�rrrrr1szJConnectionPoolTests.test_closeLogError.<locals>.ConnectionCloseRaise.closeN)rsrtrurrrrr�ConnectionCloseRaise0sr�rVrr�N)	r�r�Z_closer.r�r`rXr�r�)rr�r�r�rrr�test_closeLogError,s
z&ConnectionPoolTests.test_closeLogErrorcsjGdd�dt�}Gdd�dt�}dd�}t�}||_||_|�|�}��|t�}�fdd�}|�|�|S)	z�
        If rollback fails, L{ConnectionPool.runInteraction} raises the
        original exception and log the error of the rollback.
        c@seZdZdd�Zdd�ZdS)z^ConnectionPoolTests.test_runWithInteractionRaiseOriginalError.<locals>.ConnectionRollbackRaisecSsdSrrr�rrrr�BszgConnectionPoolTests.test_runWithInteractionRaiseOriginalError.<locals>.ConnectionRollbackRaise.__init__cSstd��dSr�r�rrrrr�EszgConnectionPoolTests.test_runWithInteractionRaiseOriginalError.<locals>.ConnectionRollbackRaise.rollbackNr�rrrrr�Asr�c@seZdZdd�ZdS)zWConnectionPoolTests.test_runWithInteractionRaiseOriginalError.<locals>.DummyTransactioncSsdSrr)rr�r�rrrr�Isz`ConnectionPoolTests.test_runWithInteractionRaiseOriginalError.<locals>.DummyTransaction.__init__N)rsrtrur�rrrr�DummyTransactionHsrcSstd��dSr�r�)rqrrrr�LszVConnectionPoolTests.test_runWithInteractionRaiseOriginalError.<locals>.raisingFunctioncs6��t�}��t|�d���|djjdd�dSr�r�r�rrrr�Us
zOConnectionPoolTests.test_runWithInteractionRaiseOriginalError.<locals>.cbFailed)r�r�r�ZtransactionFactoryrHr�r�r%)rr�rr�r�r'r�rrr�)test_runWithInteractionRaiseOriginalError<s

z=ConnectionPoolTests.test_runWithInteractionRaiseOriginalErrorcCsDtd�}td|d�}|�|jdd|jfg�|��|�|j�dS)z�
        If L{ConnectionPool.close} is called without L{ConnectionPool.start}
        having been called, the pool's startup event is cancelled.
        F�twisted.test.test_adbapi�Z
cp_reactorr�r�N)r�rr`r�Z_startrr��rrr�rrr�test_unstartedClose]s
z'ConnectionPoolTests.test_unstartedClosecCsDtd�}td|d�}|�|jdd|jfg�|��|�|j�dS)z�
        If L{ConnectionPool.close} is called after it has been started, but
        not by its shutdown trigger, the shutdown trigger is cancelled.
        TrrZduringZshutdownN)r�rr`r�Z
finalCloserr�rrrr�test_startedCloseks�z%ConnectionPoolTests.test_startedCloseN)	rsrtrurvr�r�rrrrrrrr�s!r�)'rvZ
twisted.trialrr�r�Ztwisted.enterprise.adbapirrrrZtwisted.internetrrr	Ztwisted.python.failurer
Ztwisted.python.reflectrr/r�r
ryr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�<module>s:sSE0!