#NEWLINE# @ testing . uses_deprecated ( ) #NEWLINE# def test_identity_conflict( self ) : #NEWLINE# #INDENT# ( users , User ) = ( self . tables . users , self . classes . User ) #NEWLINE# mapper ( User , u1 ) #NEWLINE# for s in ( create_session ( ) , create_session ( weak_identity_map = False ) ) : #NEWLINE# #INDENT# users . delete ( ) . execute ( ) #NEWLINE# u1 = User ( name = 'ed' ) #NEWLINE# s . add ( u1 ) #NEWLINE# s . flush ( ) #NEWLINE# s . expunge ( u1 ) #NEWLINE# u2 = s . query ( User ) . first ( ) #NEWLINE# s . expunge ( u2 ) #NEWLINE# s . identity_map . add ( sa . orm . attributes . instance_state ( u1 ) ) #NEWLINE# assert_raises_message ( sa . exc . InvalidRequestError , "Can't attach instance <User.*?>; another instance with key .*? is already present in this session." , s . identity_map . add , sa . orm . attributes . instance_state ( u2 ) )