Ñò 4äKc @ s+ d Z d d k Z d d k Z d d k Z d d k Z d d k l Z d e i d ƒ Z d „ Z d e i f d „ ƒ YZ d d d „ ƒ YZ d e f d „ ƒ YZ d d d „ ƒ YZ d e f d „ ƒ YZ d „ Z d „ Z d „ Z d „ Z d „ Z e Z e d j o e i ƒ i e ƒ ƒ n d S( s½ Test transaction behavior for variety of cases. I wrote these unittests to investigate some odd transaction behavior when doing unittests of integrating non sub transaction aware objects, and to insure proper txn behavior. these tests test the transaction system independent of the rest of the zodb. you can see the method calls to a jar by passing the keyword arg tracing to the modify method of a dataobject. the value of the arg is a prefix used for tracing print calls to that objects jar. the number of times a jar method was called can be inspected by looking at an attribute of the jar that is the method name prefixed with a c (count/check). i've included some tracing examples for tests that i thought were illuminating as doc strings below. TODO add in tests for objects which are modified multiple times, for example an object that gets modified in multiple sub txns. $Id: test_transaction.py 112144 2010-05-07 15:35:15Z tseaver $ iÿÿÿÿN( t WarningsHooki t Pc C s+ t | ƒ } | d j o | t 7} n | S( s) Return id(obj) as a non-negative integer.i ( t idt _ADDRESS_MASK( t objt result( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt positive_id2 s t TransactionTestsc B sk e Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( c C sY t i ƒ } | _ t | ƒ | _ t | ƒ | _ t | ƒ | _ t | d d ƒ| _ d S( Nt nosti ( t transactiont TransactionManagert transaction_managert DataObjectt sub1t sub2t sub3t nosub1( t selft mgr( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt setUp= s c C s+ | i i ƒ | i i ƒ | i i ƒ d S( N( R t modifyR R t commit( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testTransactionCommitG s c C s+ | i i ƒ | i i ƒ | i i ƒ d S( N( R R R R t abort( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testTransactionAbortQ s c C s] | i i ƒ } | i d ƒ | i | i d ƒ | i d ƒ | i | i d ƒ | i ƒ d S( Ns This is a note.s Another.s This is a note. Another.( R t gett notet assertEqualt descriptionR ( R t t( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testTransactionNoteZ s c C s | i i ƒ | i i ƒ d S( N( R R R R ( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testNSJTransactionCommith s c C s | i i ƒ | i i ƒ d S( N( R R R R ( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testNSJTransactionAbortp s c C sm t d d ƒ | i _ | i i ƒ | i i d d ƒ | i i ƒ y | i i ƒ Wn t j o n Xd S( Nt errorsR t nojari ( t BasicJarR t _p_jarR R R R R t TestTxnException( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testExceptionInAbort„ s c C s` t d d ƒ | i _ | i i ƒ | i i d d ƒ y | i i ƒ Wn t j o n Xd S( NR! R R" i ( R# R R$ R R R R R% ( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testExceptionInCommit“ s c C s` t d d ƒ | i _ | i i ƒ | i i d d ƒ y | i i ƒ Wn t j o n Xd S( NR! t tpc_voteR" i ( R# R R$ R R R R R% ( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testExceptionInTpcVote¢ s c C s` t d d ƒ | i _ | i i ƒ | i i d d ƒ y | i i ƒ Wn t j o n Xd S( sH ok this test reveals a bug in the TM.py as the nosub tpc_abort there is ignored. nosub calling method tpc_begin nosub calling method commit sub calling method tpc_begin sub calling method abort sub calling method tpc_abort nosub calling method tpc_abort R! t tpc_beginR" i N( R# R R$ R R R R R% ( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testExceptionInTpcBegin² s c C s` t d d ƒ | i _ | i i ƒ | i i d d ƒ y | i i ƒ Wn t j o n Xd S( NR! t tpc_abortR( R" i ( s tpc_aborts tpc_vote( R# R R$ R R R R R% ( R ( ( sF /usr/lib/python2.6/site-packages/transaction/tests/test_transaction.pyt testExceptionInTpcAbortË s ( t __name__t __module__R R R R R R R&