[pypy-svn] r76915 - pypy/trunk/pypy/module/__builtin__/test

arigo at codespeak.net arigo at codespeak.net
Tue Sep 7 14:21:45 CEST 2010


Author: arigo
Date: Tue Sep  7 14:21:43 2010
New Revision: 76915

Modified:
   pypy/trunk/pypy/module/__builtin__/test/test_classobj.py
Log:
Improve the test.


Modified: pypy/trunk/pypy/module/__builtin__/test/test_classobj.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/test/test_classobj.py	(original)
+++ pypy/trunk/pypy/module/__builtin__/test/test_classobj.py	Tue Sep  7 14:21:43 2010
@@ -786,18 +786,25 @@
                     return 42
                 return callable
         a = A()
-        a.instancevalue = 42
+        a.instancevalue = 42      # does not go via __getattr__('__setattr__')
+        a.__getattr__ = "hi there, ignore me, I'm in a"
+        a.__setattr__ = "hi there, ignore me, I'm in a too"
         assert a.instancevalue == 42
         A.classvalue = 123
         assert a.classvalue == 123
         assert a.foobar(5) == 'foobar(5,)'
-        assert a.__dict__ == {'instancevalue': 42}
+        assert a.__dict__ == {'instancevalue': 42,
+                              '__getattr__': a.__getattr__,
+                              '__setattr__': a.__setattr__}
         assert a.__class__ is A
-        # this follows the Python 2.5 rules, more precisely
+        # This follows the Python 2.5 rules, more precisely.
+        # It is still valid in Python 2.7 too.
         assert repr(a) == '__repr__()'
         assert str(a) == '__str__()'
         assert unicode(a) == u'__unicode__()'
         b = B()
+        b.__getattr__ = "hi there, ignore me, I'm in b"
+        b.__setattr__ = "hi there, ignore me, I'm in b too"
         assert 'called' not in b.__dict__      # and not e.g. ('__init__', ())
         assert len(b) == 42
         assert b.called == ('__len__', ())



More information about the Pypy-commit mailing list