#NEWLINE# def test_transaction_callable( self , r ) : #NEWLINE# #INDENT# r [ 'a' ] = 1 #NEWLINE# r [ 'b' ] = 2 #NEWLINE# has_run = [ ] #NEWLINE# def my_transaction( pipe ) : #NEWLINE# #INDENT# a_value = pipe . get ( 'a' ) #NEWLINE# assert ( a_value in ( b ( '1' ) , b ( '2' ) ) ) #NEWLINE# b_value = pipe . get ( 'b' ) #NEWLINE# assert ( b_value == b ( '2' ) ) #NEWLINE# if ( not has_run ) : #NEWLINE# #INDENT# r . incr ( 'a' ) #NEWLINE# has_run . append ( 'it has' ) #NEWLINE# #UNINDENT# pipe . multi ( ) #NEWLINE# pipe . set ( 'c' , ( int ( a_value ) + int ( b_value ) ) ) #NEWLINE# #UNINDENT# result = r . transaction ( my_transaction , 'a' , 'b' ) #NEWLINE# assert ( result == [ True ] ) #NEWLINE# assert ( my_transaction [ 'c' ] == b ( '4' ) )