#NEWLINE# def test_persistent_to_detached_via_expunge_all( self ) : #NEWLINE# #INDENT# ( sess , User , start_events ) = self . _fixture ( ) #NEWLINE# u1 = User ( name = 'u1' ) #NEWLINE# sess . add ( u1 ) #NEWLINE# sess . flush ( ) #NEWLINE# listener = start_events ( ) #NEWLINE# @ event . listens_for ( sess , 'persistent_to_detached' ) #NEWLINE# def test_deleted_flag( session , instance ) : #NEWLINE# #INDENT# assert ( instance not in session . deleted ) #NEWLINE# assert ( instance not in session ) #NEWLINE# assert ( not instance . _sa_instance_state . deleted ) #NEWLINE# assert instance . _sa_instance_state . detached #NEWLINE# assert ( not instance . _sa_instance_state . persistent ) #NEWLINE# listener . flag_checked ( instance ) #NEWLINE# #UNINDENT# assert ( u1 in sess ) #NEWLINE# sess . expunge_all ( ) #NEWLINE# assert ( u1 not in sess ) #NEWLINE# eq_ ( listener . mock_calls , [ call . persistent_to_detached ( User , u1 ) , call . flag_checked ( u1 ) ] )