Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/sqlite3/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/sqlite3/test/__pycache__/transactions.cpython-35.opt-2.pyc



���]B�@s�ddlZddlZddlZdd�ZGdd�dej�ZGdd�dej�Zdd	�Zd
d�Z	e
dkr�e	�dS)
�NcCsdS)NZ
sqlite_testdb�rrr�1/opt/alt/python35/lib64/python3.5/transactions.py�get_db_pathsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
eje
jdkd�dd��Zeje
jdkd�dd��Zdd�ZdS)�TransactionTestscCs�ytjt��Wntk
r(YnXtjt�dd�|_|jj�|_tjt�dd�|_	|j	j�|_
dS)N�timeoutg�������?)�os�remover�OSError�sqlite�connect�con1�cursor�cur1�con2�cur2)�selfrrr�setUps
zTransactionTests.setUpcCsa|jj�|jj�|jj�|jj�ytjt��Wntk
r\YnXdS)N)	r�closerrrr�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)rrrrrr)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�)rrr�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)rrrrrrrr)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)rrrrrrrr)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)rrrZisolation_levelrrrr)rrrrr�CheckToggleAutoCommitbsz&TransactionTests.CheckToggleAutoCommit��z.test hangs on sqlite versions older than 3.2.2c	CsN|jjd�|jjd�|jtj��|jjd�WdQRXdS)Nzcreate table test(i)zinsert into test(i) values (5))rr�assertRaisesr
�OperationalErrorr)rrrr�CheckRaiseTimeoutrsz"TransactionTests.CheckRaiseTimeoutc	Cs[|jjd�|jjd�|jtj��|jjd�WdQRX|jj�dS)Nzcreate table test(i)zinsert into test(i) values (5))rrr&r
r'rrr)rrrr�CheckLockingzs
zTransactionTests.CheckLockingc	Csttjd�}|j�}|jd�|jd�|jd�|j�|jtj��|j�WdQRXdS)Nz:memory:zcreate table test(x)zinsert into test(x) values (5)z&select 1 union select 2 union select 3)r
rr
rZrollbackr&ZInterfaceErrorr)r�con�currrr�CheckRollbackCursorConsistency�s



z/TransactionTests.CheckRollbackCursorConsistencyN)r$r%r%)r$r%r%)�__name__�
__module__�__qualname__rrrrr r!r"r#�unittestZskipIfr
Zsqlite_version_infor(r)r,rrrrrs		

rc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�SpecialCommandTestscCs(tjd�|_|jj�|_dS)Nz:memory:)r
rr*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.r/rr2r3r4rrrrrr1�s
r1cCs7tjtd�}tjtd�}tj||f�S)NZCheck)r0Z	makeSuiterr1Z	TestSuite)Z
default_suiteZspecial_command_suiterrr�suite�sr5cCs tj�}|jt��dS)N)r0ZTextTestRunner�runr5)Zrunnerrrr�test�sr7�__main__)rr0Zsqlite3r
rZTestCaserr1r5r7r-rrrr�<module>sy