f ž _§c@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_pathórc@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š™™™™™¹?)Ztimeout) ÚosZremoverÚOSErrorÚsqliteÚconnectÚcon1ÚcursorÚcur1Úcon2Úcur2©ÚselfrrrÚsetUps  zTransactionTests.setUpcCsP|j ¡|j ¡|j ¡|j ¡zt tƒ¡WntyJYn0dS©N) r Úcloser rr rZunlinkrrrrrrÚ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©rZresrrrÚCheckDMLDoesNotAutoCommitBefore7s      z0TransactionTests.CheckDMLDoesNotAutoCommitBeforecCsB|j d¡|j d¡|j d¡|j ¡}| t|ƒd¡dS)NrrrrrrrrrÚCheckInsertStartsTransaction?s     z-TransactionTests.CheckInsertStartsTransactioncCsX|j d¡|j d¡|j ¡|j d¡|j d¡|j ¡d}| |d¡dS)Nrrzupdate test set i=6rré)r rr ÚcommitrZfetchonerrrrrÚCheckUpdateStartsTransactionFs     z-TransactionTests.CheckUpdateStartsTransactioncCsX|j d¡|j d¡|j ¡|j d¡|j d¡|j ¡}| t|ƒd¡dS)Nrrzdelete from testré©r rr r!rrrrrrrrÚ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$rrrrÚ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)r rr Zisolation_levelrrrrrrrrÚCheckToggleAutoCommitbs       z&TransactionTests.CheckToggleAutoCommitcCsT|j d¡|j d¡| tj¡|j d¡Wdƒn1sF0YdS)Nrr)r rÚ 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)r rr(rr)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)rr r rÚrollbackr(ZInterfaceErrorr)rÚconÚcurrrrÚCheckRollbackCursorConsistency„s    z/TransactionTests.CheckRollbackCursorConsistencyN)Ú__name__Ú __module__Ú __qualname__rrrrr"r%r&r'r*r+r0rrrrrs      rc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚSpecialCommandTestscCst d¡|_|j ¡|_dS©Nr,)rr r.r r/rrrrr”s zSpecialCommandTests.setUpcCó(|j d¡|j d¡|j d¡dS)Nrrzdrop table test©r/rrrrrÚCheckDropTable˜ó  z"SpecialCommandTests.CheckDropTablecCr6)Nrrzpragma count_changes=1r7rrrrÚ CheckPragmar9zSpecialCommandTests.CheckPragmacCs|j ¡|j ¡dSr)r/rr.rrrrr¢s zSpecialCommandTests.tearDownN)r1r2r3rr8r:rrrrrr4“sr4c@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) ÚTransactionalDDLcCst d¡|_dSr5)rr r.rrrrr§rzTransactionalDDL.setUpcCs6|j d¡|j ¡|j d¡ ¡}| |g¡dS)Nrúselect * from test)r.rr-rr)rZresultrrrÚ#CheckDdlDoesNotAutostartTransactionªs  z4TransactionalDDL.CheckDdlDoesNotAutostartTransactioncCó^|j d¡|j d¡|j ¡| tj¡|j d¡Wdƒn1sP0YdS)Nzbegin immediaterr<©r.rr-r(rr)rrrrÚCheckImmediateTransactionalDDL²ó    z/TransactionalDDL.CheckImmediateTransactionalDDLcCr>)NZbeginrr<r?rrrrÚCheckTransactionalDDL»rAz&TransactionalDDL.CheckTransactionalDDLcCs|j ¡dSr)r.rrrrrrÄrzTransactionalDDL.tearDownN)r1r2r3rr=r@rBrrrrrr;¦s   r;cCs4t td¡}t td¡}t td¡}t |||f¡S)NZCheck)ÚunittestZ makeSuiterr4r;Z TestSuite)Z default_suiteZspecial_command_suiteZ ddl_suiterrrÚsuiteÇs   rDcCst ¡}| tƒ¡dSr)rCZTextTestRunnerZrunrD)ZrunnerrrrÚtestÍsrEZ__main__) rrCZsqlite3rrZTestCaserr4r;rDrEr1rrrrZsu!