#NEWLINE# def test_loaded_as_persistent( self ) : #NEWLINE# #INDENT# ( sess , User , start_events ) = self . _fixture ( ) #NEWLINE# u1 = User ( name = 'u1' ) #NEWLINE# sess . add ( u1 ) #NEWLINE# sess . commit ( ) #NEWLINE# sess . close ( ) #NEWLINE# listener = start_events ( ) #NEWLINE# @ event . listens_for ( sess , 'loaded_as_persistent' ) #NEWLINE# def test_identity_flag( session , instance ) : #NEWLINE# #INDENT# assert ( instance in session ) #NEWLINE# assert instance . _sa_instance_state . persistent #NEWLINE# assert ( instance . _sa_instance_state . key in session . identity_map ) #NEWLINE# assert ( not instance . _sa_instance_state . deleted ) #NEWLINE# assert ( not instance . _sa_instance_state . detached ) #NEWLINE# assert instance . _sa_instance_state . persistent #NEWLINE# listener . flag_checked ( instance ) #NEWLINE# #UNINDENT# u1 = sess . query ( User ) . filter_by ( name = 'u1' ) . one ( ) #NEWLINE# eq_ ( listener . mock_calls , [ call . loaded_as_persistent ( sess , u1 ) , call . flag_checked ( u1 ) ] )