diff options
author | Guido van Rossum <guido@python.org> | 2001-08-09 19:45:21 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-09 19:45:21 (GMT) |
commit | 3720261729d734c8d85d05686ae2e18cf6ba1929 (patch) | |
tree | 29112c0f729a591b765edc65bd24c482958ec7bc /Lib | |
parent | 29687cd2112c540a8a4d31cf3b191cf10db08412 (diff) | |
download | cpython-3720261729d734c8d85d05686ae2e18cf6ba1929.zip cpython-3720261729d734c8d85d05686ae2e18cf6ba1929.tar.gz cpython-3720261729d734c8d85d05686ae2e18cf6ba1929.tar.bz2 |
Restore the test for 'object' that I removed when object was
uninstantiable. All is well now.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 5b5f137..92f79d5 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -472,6 +472,29 @@ def diamond(): verify(G().boo() == "C") 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__..." class C0(object): @@ -789,6 +812,7 @@ def all(): pymods() multi() diamond() + objects() slots() dynamics() errors() |