#NEWLINE# def test_make_transient( self ) : #NEWLINE# #INDENT# ( users , User ) = ( self . tables . users , self . classes . User ) #NEWLINE# mapper ( User , users ) #NEWLINE# sess = create_session ( ) #NEWLINE# sess . add ( User ( name = 'test' ) ) #NEWLINE# sess . flush ( ) #NEWLINE# u1 = sess . query ( User ) . first ( ) #NEWLINE# make_transient ( u1 ) #NEWLINE# assert ( u1 not in sess ) #NEWLINE# sess . add ( u1 ) #NEWLINE# assert ( u1 in sess . new ) #NEWLINE# u1 = sess . query ( User ) . first ( ) #NEWLINE# sess . expunge ( u1 ) #NEWLINE# make_transient ( u1 ) #NEWLINE# sess . add ( u1 ) #NEWLINE# assert ( u1 in sess . new ) #NEWLINE# u1 = sess . query ( User ) . first ( ) #NEWLINE# sess . expire ( u1 ) #NEWLINE# make_transient ( u1 ) #NEWLINE# assert ( u1 . id is None ) #NEWLINE# assert ( u1 . name is None ) #NEWLINE# make_transient ( u1 ) #NEWLINE# sess . close ( ) #NEWLINE# u1 . name = 'test2' #NEWLINE# sess . add ( u1 ) #NEWLINE# sess . flush ( ) #NEWLINE# assert ( u1 in sess ) #NEWLINE# sess . delete ( u1 ) #NEWLINE# sess . flush ( ) #NEWLINE# assert ( u1 not in sess ) #NEWLINE# assert_raises ( sa . exc . InvalidRequestError , sess . add , u1 ) #NEWLINE# make_transient ( u1 ) #NEWLINE# sess . add ( u1 ) #NEWLINE# sess . flush ( ) #NEWLINE# assert ( u1 in sess )