Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3720261

Browse files
committed
Restore the test for 'object' that I removed when object was
uninstantiable. All is well now.
1 parent 29687cd commit 3720261

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lib/test/test_descr.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,29 @@ class G(E, D): pass
472472
verify(G().boo() == "C")
473473
verify(G.__mro__ == (G, E, D, C, B, A, object))
474474

475+
def objects():
476+
if verbose: print "Testing object class..."
477+
a = object()
478+
verify(a.__class__ == object == type(a))
479+
b = object()
480+
verify(a is not b)
481+
verify(not hasattr(a, "foo"))
482+
try:
483+
a.foo = 12
484+
except TypeError:
485+
pass
486+
else:
487+
verify(0, "object() should not allow setting a foo attribute")
488+
verify(not hasattr(object(), "__dict__"))
489+
490+
class Cdict(object):
491+
pass
492+
x = Cdict()
493+
verify(x.__dict__ is None)
494+
x.foo = 1
495+
verify(x.foo == 1)
496+
verify(x.__dict__ == {'foo': 1})
497+
475498
def slots():
476499
if verbose: print "Testing __slots__..."
477500
class C0(object):
@@ -789,6 +812,7 @@ def all():
789812
pymods()
790813
multi()
791814
diamond()
815+
objects()
792816
slots()
793817
dynamics()
794818
errors()

0 commit comments

Comments
 (0)