f ž _§ã@sxddlZddlZddlZdd„ZGdd„dejƒZGdd„dejƒZGdd „d ejƒZd d „Z d d „Z e dkrte ƒdS)éNcCsdS)NZ sqlite_testdb©rrrú2/usr/lib64/python3.10/sqlite3/test/transactions.pyÚ get_db_pathsrc@sdeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dS)ÚTransactionTestscCsdzt tƒ¡Wnty"Yn0tjtƒdd|_|j ¡|_tjtƒdd|_ |j  ¡|_ dS)Ngš™™™™™¹?)Útimeout) ÚosÚremoverÚOSErrorÚsqliteÚconnectÚcon1ÚcursorÚcur1Úcon2Úcur2©ÚselfrrrÚsetUps  zTransactionTests.setUpcCsP|j ¡|j ¡|j ¡|j ¡zt tƒ¡WntyJYn0dS©N) rÚcloser rrrÚunlinkrr rrrrÚtearDown+s     zTransactionTests.tearDowncCsN|j d¡|j d¡|j d¡|j d¡|j ¡}| t|ƒd¡dS)Núcreate table test(i)úinsert into test(i) values (5)zcreate table test2(j)úselect i from testr©rÚexecuterÚfetchallÚ assertEqualÚlen©rÚresrrrÚCheckDMLDoesNotAutoCommitBefore7s      z0TransactionTests.CheckDMLDoesNotAutoCommitBeforecCsB|j d¡|j d¡|j d¡|j ¡}| t|ƒd¡dS)Nrrrrrr rrrÚCheckInsertStartsTransaction?s     z-TransactionTests.CheckInsertStartsTransactioncCsX|j d¡|j d¡|j ¡|j d¡|j d¡|j ¡d}| |d¡dS)Nrrzupdate test set i=6rré)rrr ÚcommitrZfetchonerr rrrÚCheckUpdateStartsTransactionFs     z-TransactionTests.CheckUpdateStartsTransactioncCsX|j d¡|j d¡|j ¡|j d¡|j d¡|j ¡}| t|ƒd¡dS)Nrrzdelete from testré©rrr r%rrrrr rrrÚCheckDeleteStartsTransactionOs      z-TransactionTests.CheckDeleteStartsTransactioncCsl|j d¡|j d¡|j ¡|j d¡|j d¡|j ¡}| t|ƒd¡| |ddd¡dS)Nrrzreplace into test(i) values (6)rr'rr$r(r rrrÚCheckReplaceStartsTransactionXs      z.TransactionTests.CheckReplaceStartsTransactioncCs¤|j d¡|j d¡d|j_| |jjd¡|j d¡|j ¡}| t|ƒd¡d|j_| |jjd¡|j d¡|j d¡|j ¡}| t|ƒd¡dS)Nrrrr'ZDEFERRED)rrr Zisolation_levelrrrrr rrrÚCheckToggleAutoCommitbs       z&TransactionTests.CheckToggleAutoCommitcCsT|j d¡|j d¡| tj¡|j d¡Wdƒn1sF0YdS)Nrr)rrÚ assertRaisesr ÚOperationalErrorrrrrrÚCheckRaiseTimeoutrs  z"TransactionTests.CheckRaiseTimeoutcCs^|j d¡|j d¡| tj¡|j d¡Wdƒn1sF0Y|j ¡dS)z This tests the improved concurrency with pysqlite 2.3.4. You needed to roll back con2 before you could commit con1. rrN)rrr,r r-rr r%rrrrÚ CheckLockingxs   *zTransactionTests.CheckLockingcCspt d¡}| ¡}| d¡| d¡| d¡| ¡| tj¡| ¡Wdƒn1sb0YdS)z… Checks if cursors on the connection are set into a "reset" state when a rollback is done on the connection. ú:memory:zcreate table test(x)zinsert into test(x) values (5)z&select 1 union select 2 union select 3N)r r r rÚrollbackr,ZInterfaceErrorr)rÚconÚcurrrrÚCheckRollbackCursorConsistency„s    z/TransactionTests.CheckRollbackCursorConsistencyN)Ú__name__Ú __module__Ú __qualname__rrr"r#r&r)r*r+r.r/r4rrrrrs      rc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚSpecialCommandTestscCst d¡|_|j ¡|_dS©Nr0)r r r2r r3rrrrr”s zSpecialCommandTests.setUpcCs(|j d¡|j d¡|j d¡dS)Nrrzdrop table test©r3rrrrrÚCheckDropTable˜s  z"SpecialCommandTests.CheckDropTablecCs(|j d¡|j d¡|j d¡dS)Nrrzpragma count_changes=1r:rrrrÚ CheckPragmas  zSpecialCommandTests.CheckPragmacCs|j ¡|j ¡dSr)r3rr2rrrrr¢s zSpecialCommandTests.tearDownN)r5r6r7rr;r<rrrrrr8“sr8c@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) ÚTransactionalDDLcCst d¡|_dSr9)r r r2rrrrr§szTransactionalDDL.setUpcCs6|j d¡|j ¡|j d¡ ¡}| |g¡dS)Nrúselect * from test)r2rr1rr)rÚresultrrrÚ#CheckDdlDoesNotAutostartTransactionªs  z4TransactionalDDL.CheckDdlDoesNotAutostartTransactioncCs^|j d¡|j d¡|j ¡| tj¡|j d¡Wdƒn1sP0YdS)Nzbegin immediaterr>©r2rr1r,r r-rrrrÚCheckImmediateTransactionalDDL²s    z/TransactionalDDL.CheckImmediateTransactionalDDLcCs^|j d¡|j d¡|j ¡| tj¡|j d¡Wdƒn1sP0YdS)NZbeginrr>rArrrrÚCheckTransactionalDDL»s    z&TransactionalDDL.CheckTransactionalDDLcCs|j ¡dSr)r2rrrrrrÄszTransactionalDDL.tearDownN)r5r6r7rr@rBrCrrrrrr=¦s   r=cCs4t td¡}t td¡}t td¡}t |||f¡S)NZCheck)ÚunittestZ makeSuiterr8r=Z TestSuite)Z default_suiteZspecial_command_suiteZ ddl_suiterrrÚsuiteÇs   rEcCst ¡}| tƒ¡dSr)rDZTextTestRunnerÚrunrE)ZrunnerrrrÚtestÍsrGÚ__main__) rrDZsqlite3r rZTestCaserr8r=rErGr5rrrrÚsu!