def test_raise_attrerror():
 class A:
  def __getattr__(self, name):
   raise AttributeError, 'get outta here'
  def __repr__(self):
   return 'foo'
 class B:
  def __getattr__(self, name):
   raise AttributeError, 'get outta here'
  def __str__(self):
   return 'foo'
 AreEqual(str(A()), 'foo')
 AreEqual(repr(A()), 'foo')
 AreEqual(str(B()), 'foo')
 Assert((repr(B()).find('B instance') != (-1)))

def test_raise_attrerror ( ) : class A : def __getattr__ ( self , name ) : raise AttributeError , 'get outta here' def __repr__ ( self ) : return 'foo' class B : def __getattr__ ( self , name ) : raise AttributeError , 'get outta here' def __str__ ( self ) : return 'foo' AreEqual ( str ( A ( ) ) , 'foo' ) AreEqual ( repr ( A ( ) ) , 'foo' ) AreEqual ( str ( B ( ) ) , 'foo' ) Assert ( ( repr ( B ( ) ) . find ( 'B instance' ) != ( - 1 ) ) )
raising attributeerror from __getattr__ should be ok .