def test_sharedmethod_reuse_on_subclasses():
 class AMeta(type, ):
  def foo(cls):
   return cls.x
 six.add_metaclass(AMeta)
 class A(object, ):
  x = 3
  def __init__(self, x):
   self.x = x
  @sharedmethod
  def foo(self):
   return self.x
 a1 = A(1)
 a2 = A(2)
 assert (a1.foo() == 1)
 assert (a2.foo() == 2)
 assert (A.foo() == 3)
 class B(A, ):
  x = 5
 assert (B.foo() == 5)

def test_sharedmethod_reuse_on_subclasses ( ) : class AMeta ( type , ) : def foo ( cls ) : return cls . x six . add_metaclass ( AMeta ) class A ( object , ) : x = 3 def __init__ ( self , x ) : self . x = x @ sharedmethod def foo ( self ) : return self . x a1 = A ( 1 ) a2 = A ( 2 ) assert ( a1 . foo ( ) == 1 ) assert ( a2 . foo ( ) == 2 ) assert ( A . foo ( ) == 3 ) class B ( A , ) : x = 5 assert ( B . foo ( ) == 5 )
regression test for an issue where sharedmethod would bind to one class for all time .