[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.3,1.4
Guido van Rossum
gvanrossum@users.sourceforge.net
2001年8月09日 12:45:23 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv19380
Modified Files:
test_descr.py
Log Message:
Restore the test for 'object' that I removed when object was
uninstantiable. All is well now.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_descr.py 2001年08月07日 16:53:42 1.3
--- test_descr.py 2001年08月09日 19:45:21 1.4
***************
*** 473,476 ****
--- 473,499 ----
verify(G.__mro__ == (G, E, D, C, B, A, object))
+ def objects():
+ if verbose: print "Testing object class..."
+ a = object()
+ verify(a.__class__ == object == type(a))
+ b = object()
+ verify(a is not b)
+ verify(not hasattr(a, "foo"))
+ try:
+ a.foo = 12
+ except TypeError:
+ pass
+ else:
+ verify(0, "object() should not allow setting a foo attribute")
+ verify(not hasattr(object(), "__dict__"))
+
+ class Cdict(object):
+ pass
+ x = Cdict()
+ verify(x.__dict__ is None)
+ x.foo = 1
+ verify(x.foo == 1)
+ verify(x.__dict__ == {'foo': 1})
+
def slots():
if verbose: print "Testing __slots__..."
***************
*** 790,793 ****
--- 813,817 ----
multi()
diamond()
+ objects()
slots()
dynamics()