mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Restore the test for 'object' that I removed when object was
uninstantiable. All is well now.
This commit is contained in:
parent
29687cd211
commit
3720261729
1 changed files with 24 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue