#NEWLINE# def test_autoflush_rollback( self ) : #NEWLINE# #INDENT# ( Address , addresses , users , User ) = ( self . classes . Address , self . tables . addresses , self . tables . users , self . classes . User ) #NEWLINE# mapper ( Address , addresses ) #NEWLINE# mapper ( User , users , properties = { #NEWLINE# #INDENT# 'addresses' : relationship ( Address ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# sess = create_session ( autocommit = False , autoflush = True ) #NEWLINE# u = sess . query ( User ) . get ( 8 ) #NEWLINE# newad = Address ( email_address = 'a new address' ) #NEWLINE# u . addresses . append ( newad ) #NEWLINE# u . name = 'some new name' #NEWLINE# assert ( u . name == 'some new name' ) #NEWLINE# assert ( len ( u . addresses ) == 4 ) #NEWLINE# assert ( newad in u . addresses ) #NEWLINE# sess . rollback ( ) #NEWLINE# assert ( u . name == 'ed' ) #NEWLINE# assert ( len ( u . addresses ) == 3 ) #NEWLINE# assert ( newad not in u . addresses ) #NEWLINE# assert ( newad . email_address == 'a new address' )