def test_binary_operator_subclass():
 class A(object, ):
  def __add__(self, other):
   return ('a', self.__class__.__name__)
  __radd__ = __add__
 class B(A, ):
  def __add__(self, other):
   return ('b', self.__class__.__name__)
  __radd__ = __add__
 class C(A, ):
  pass
 a = A()
 b = B()
 c = C()
 AreEqual((a + b), ('b', 'B'))
 AreEqual((a + c), ('a', 'A'))

def test_binary_operator_subclass ( ) : class A ( object , ) : def __add__ ( self , other ) : return ( 'a' , self . __class__ . __name__ ) __radd__ = __add__ class B ( A , ) : def __add__ ( self , other ) : return ( 'b' , self . __class__ . __name__ ) __radd__ = __add__ class C ( A , ) : pass a = A ( ) b = B ( ) c = C ( ) AreEqual ( ( a + b ) , ( 'b' , 'B' ) ) AreEqual ( ( a + c ) , ( 'a' , 'A' ) )
subclassing but not overriding shouldnt call __radd__ .