Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/sqlite3/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/sqlite3/test/__pycache__/transactions.cpython-34.pyc

�
e f��@s�ddlZddlZddlZdd�ZGdd�dej�ZGdd�dej�Zdd	�Zd
d�Z	e
dkr�e	�ndS)
�NcCsdS)NZ
sqlite_testdb�rrr�>/opt/alt/python34/lib64/python3.4/sqlite3/test/transactions.py�get_db_pathsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TransactionTestscCs�ytjt��Wntk
r(YnXtjt�dd�|_|jj�|_tjt�dd�|_	|j	j�|_
dS)NZtimeoutg�������?)�os�remover�OSError�sqlite�connect�con1�cursor�cur1�con2�cur2)�selfrrr�setUps
zTransactionTests.setUpcCsa|jj�|jj�|jj�|jj�ytjt��Wntk
r\YnXdS)N)	r
�closerrrr�unlinkrr)rrrr�tearDown+s




zTransactionTests.tearDowncCsi|jjd�|jjd�|jjd�|jjd�|jj�}|jt|�d�dS)Nzcreate table test(i)zinsert into test(i) values (5)zcreate table test2(j)zselect i from test�)r
�executer�fetchall�assertEqual�len)r�resrrr�CheckDMLdoesAutoCommitBefore7sz-TransactionTests.CheckDMLdoesAutoCommitBeforecCsY|jjd�|jjd�|jjd�|jj�}|jt|�d�dS)Nzcreate table test(i)zinsert into test(i) values (5)zselect i from testr)r
rrrrr)rrrrr�CheckInsertStartsTransaction?s
z-TransactionTests.CheckInsertStartsTransactioncCst|jjd�|jjd�|jj�|jjd�|jjd�|jj�d}|j|d�dS)Nzcreate table test(i)zinsert into test(i) values (5)zupdate test set i=6zselect i from testr�)r
rr�commitrZfetchoner)rrrrr�CheckUpdateStartsTransactionFs
z-TransactionTests.CheckUpdateStartsTransactioncCsv|jjd�|jjd�|jj�|jjd�|jjd�|jj�}|jt|�d�dS)Nzcreate table test(i)zinsert into test(i) values (5)zdelete from testzselect i from testr)r
rrrrrrr)rrrrr�CheckDeleteStartsTransactionOs
z-TransactionTests.CheckDeleteStartsTransactioncCs�|jjd�|jjd�|jj�|jjd�|jjd�|jj�}|jt|�d�|j|ddd�dS)Nzcreate table test(i)zinsert into test(i) values (5)zreplace into test(i) values (6)zselect i from testrrr)r
rrrrrrr)rrrrr�CheckReplaceStartsTransactionXs
z.TransactionTests.CheckReplaceStartsTransactioncCs�|jjd�|jjd�d|j_|j|jjd�|jjd�|jj�}|jt|�d�d|j_|j|jjd�|jjd�|jjd�|jj�}|jt|�d�dS)Nzcreate table test(i)zinsert into test(i) values (5)zselect i from testrZDEFERRED)r
rrZisolation_levelrrrr)rrrrr�CheckToggleAutoCommitbsz&TransactionTests.CheckToggleAutoCommitcCs�tjdkrdS|jjd�|jjd�y!|jjd�|jd�Wn)tjk
rkYn|jd�YnXdS)N��zcreate table test(i)zinsert into test(i) values (5)z&should have raised an OperationalError)r#r$r$)r	�sqlite_version_infor
rr�fail�OperationalError)rrrr�CheckRaiseTimeoutrsz"TransactionTests.CheckRaiseTimeoutcCs�tjdkrdS|jjd�|jjd�y!|jjd�|jd�Wn)tjk
rkYn|jd�YnX|jj�dS)z�
        This tests the improved concurrency with pysqlite 2.3.4. You needed
        to roll back con2 before you could commit con1.
        r#r$Nzcreate table test(i)zinsert into test(i) values (5)z&should have raised an OperationalError)r#r$r$)	r	r%r
rrr&r'rr)rrrr�CheckLocking�szTransactionTests.CheckLockingcCs�tjd�}|j�}|jd�|jd�|jd�|j�y|j�|jd�Wn<tjk
r�}zWYdd}~Xn|jd�YnXdS)z�
        Checks if cursors on the connection are set into a "reset" state
        when a rollback is done on the connection.
        z:memory:zcreate table test(x)zinsert into test(x) values (5)z&select 1 union select 2 union select 3z&InterfaceError should have been raisedN)r	r
rrZrollbackrr&ZInterfaceError)r�con�cur�errr�CheckRollbackCursorConsistency�s




z/TransactionTests.CheckRollbackCursorConsistencyN)�__name__�
__module__�__qualname__rrrrrr r!r"r(r)r-rrrrrs		
rc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�SpecialCommandTestscCs(tjd�|_|jj�|_dS)Nz:memory:)r	r
r*rr+)rrrrr�szSpecialCommandTests.setUpcCs4|jjd�|jjd�|jjd�dS)Nzcreate table test(i)zinsert into test(i) values (5)Zvacuum)r+r)rrrr�CheckVacuum�szSpecialCommandTests.CheckVacuumcCs4|jjd�|jjd�|jjd�dS)Nzcreate table test(i)zinsert into test(i) values (5)zdrop table test)r+r)rrrr�CheckDropTable�sz"SpecialCommandTests.CheckDropTablecCs4|jjd�|jjd�|jjd�dS)Nzcreate table test(i)zinsert into test(i) values (5)zpragma count_changes=1)r+r)rrrr�CheckPragma�szSpecialCommandTests.CheckPragmacCs|jj�|jj�dS)N)r+rr*)rrrrr�s
zSpecialCommandTests.tearDownN)r.r/r0rr2r3r4rrrrrr1�s
r1cCs7tjtd�}tjtd�}tj||f�S)NZCheck)�unittestZ	makeSuiterr1Z	TestSuite)Z
default_suiteZspecial_command_suiterrr�suite�sr6cCs tj�}|jt��dS)N)r5ZTextTestRunnerZrunr6)Zrunnerrrr�test�sr7�__main__)rr5Zsqlite3r	rZTestCaserr1r6r7r.rrrr�<module>s�