Also fix the test by having the test classes inherit from object.
Are the getter/setter/deleter attributes supposed to be able to chain? As of
right now they can't as the property tries to call what the property returns,
which is another property when they are chained.
def properties_plus():
- class C:
+ class C(object):
foo = property(doc="hello")
@foo.getter
def foo(self):
assert C.foo.__doc__ == "hello"
assert not hasattr(c, "foo")
c.foo = -42
+ assert hasattr(c, '_foo')
+ assert c._foo == 42
assert c.foo == 42
del c.foo
+ assert not hasattr(c, '_foo')
assert not hasattr(c, "foo")
class D(C):
del d.foo
del d.foo
- class E:
+ class E(object):
@property
def foo(self):
return self._foo
@foo.setter
- def foo (self, value):
+ def foo(self, value):
raise RuntimeError
@foo.setter
+ def foo(self, value):
+ self._foo = abs(value)
@foo.deleter
def foo(self, value=None):
- if value is None:
- del self._foo
- else:
- self._foo = abs(value)
+ del self._foo
+
e = E()
e.foo = -42
assert e.foo == 42
f.foo = -10
assert f.foo == 0
del f.foo
+ print "*** HIT"
def supers():
recursions()
weakrefs()
properties()
+ properties_plus()
supers()
inherits()
keywords()