#NEWLINE# def test_inheritance( self ) : #NEWLINE# #INDENT# 'tests that attributes are polymorphic' #NEWLINE# for base in ( object , MyBaseClass , MyClass ) : #NEWLINE# #INDENT# class Foo ( base ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# class Bar ( Foo ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# register_class ( Foo ) #NEWLINE# register_class ( Bar ) #NEWLINE# def func1( state , passive ) : #NEWLINE# #INDENT# return 'this is the foo attr' #NEWLINE# #UNINDENT# def func2( state , passive ) : #NEWLINE# #INDENT# return 'this is the bar attr' #NEWLINE# #UNINDENT# def func3( state , passive ) : #NEWLINE# #INDENT# return 'this is the shared attr' #NEWLINE# #UNINDENT# attributes . register_attribute ( Foo , 'element' , uselist = False , callable_ = func1 , useobject = True ) #NEWLINE# attributes . register_attribute ( Foo , 'element2' , uselist = False , callable_ = func3 , useobject = True ) #NEWLINE# attributes . register_attribute ( Bar , 'element' , uselist = False , callable_ = func2 , useobject = True ) #NEWLINE# x = Foo ( ) #NEWLINE# y = Bar ( ) #NEWLINE# assert ( x . element == 'this is the foo attr' ) #NEWLINE# assert ( y . element == 'this is the bar attr' ) , self . element #NEWLINE# assert ( x . element2 == 'this is the shared attr' ) #NEWLINE# assert ( y . element2 == 'this is the shared attr' )