#NEWLINE# def test_parenttrack( self ) : #NEWLINE# #INDENT# class Foo ( object ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# class Bar ( object ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# instrumentation . register_class ( Foo ) #NEWLINE# instrumentation . register_class ( Bar ) #NEWLINE# attributes . register_attribute ( Foo , 'element' , uselist = False , trackparent = True , useobject = True ) #NEWLINE# attributes . register_attribute ( Bar , 'element' , uselist = False , trackparent = True , useobject = True ) #NEWLINE# f1 = Foo ( ) #NEWLINE# f2 = Foo ( ) #NEWLINE# b1 = Bar ( ) #NEWLINE# b2 = Bar ( ) #NEWLINE# f1 . element = f1 #NEWLINE# b2 . element = f2 #NEWLINE# assert attributes . has_parent ( Foo , b1 , 'element' ) #NEWLINE# assert ( not attributes . has_parent ( Foo , b2 , 'element' ) ) #NEWLINE# assert ( not attributes . has_parent ( Foo , f2 , 'element' ) ) #NEWLINE# assert attributes . has_parent ( Bar , f2 , 'element' ) #NEWLINE# b2 . element = None #NEWLINE# assert ( not attributes . has_parent ( Bar , f2 , 'element' ) ) #NEWLINE# b3 = Bar ( ) #NEWLINE# f4 = Foo ( ) #NEWLINE# b3 . element = f4 #NEWLINE# assert attributes . has_parent ( Bar , f4 , 'element' ) #NEWLINE# b3 . element = f4 #NEWLINE# assert attributes . has_parent ( Bar , f4 , 'element' )