#NEWLINE# def test_collections_via_backref( self ) : #NEWLINE# #INDENT# class Foo ( fixtures . BasicEntity ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# class Bar ( fixtures . BasicEntity ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# instrumentation . register_class ( Foo ) #NEWLINE# instrumentation . register_class ( Bar ) #NEWLINE# attributes . register_attribute ( Foo , 'bars' , uselist = True , backref = 'foo' , trackparent = True , useobject = True ) #NEWLINE# attributes . register_attribute ( Bar , 'foo' , uselist = False , backref = 'bars' , trackparent = True , useobject = True ) #NEWLINE# f1 = Foo ( ) #NEWLINE# b1 = Bar ( ) #NEWLINE# eq_ ( attributes . get_state_history ( attributes . instance_state ( f1 ) , 'bars' ) , ( ( ) , [ ] , ( ) ) ) #NEWLINE# eq_ ( attributes . get_state_history ( attributes . instance_state ( b1 ) , 'foo' ) , ( ( ) , ( ) , ( ) ) ) #NEWLINE# f1 . bars . append ( b1 ) #NEWLINE# eq_ ( attributes . get_state_history ( attributes . instance_state ( f1 ) , 'bars' ) , ( [ b1 ] , [ ] , [ ] ) ) #NEWLINE# eq_ ( attributes . get_state_history ( attributes . instance_state ( b1 ) , 'foo' ) , ( [ f1 ] , ( ) , ( ) ) ) #NEWLINE# b2 = Bar ( ) #NEWLINE# f1 . bars . append ( b2 ) #NEWLINE# eq_ ( attributes . get_state_history ( attributes . instance_state ( f1 ) , 'bars' ) , ( [ b1 , b2 ] , [ ] , [ ] ) ) #NEWLINE# eq_ ( attributes . get_state_history ( attributes . instance_state ( b1 ) , 'foo' ) , ( [ self ] , ( ) , ( ) ) ) #NEWLINE# eq_ ( attributes . get_state_history ( attributes . instance_state ( b2 ) , 'foo' ) , ( [ f1 ] , ( ) , ( ) ) )