Commit fd68083c authored by Robert Bradshaw's avatar Robert Bradshaw

Extend property test.

parent 03607398
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# ticket: 593 # ticket: 593
# tag: property, decorator # tag: property, decorator
my_property = property
class Prop(object): class Prop(object):
""" """
>>> p = Prop() >>> p = Prop()
...@@ -17,6 +19,12 @@ class Prop(object): ...@@ -17,6 +19,12 @@ class Prop(object):
>>> p.prop >>> p.prop
GETTING '2' GETTING '2'
2 2
>>> del p.prop
DELETING (previously: '2')
>>> p.my_prop
GETTING 'my_prop'
389
""" """
_value = None _value = None
...@@ -29,3 +37,13 @@ class Prop(object): ...@@ -29,3 +37,13 @@ class Prop(object):
def prop(self, value): def prop(self, value):
print("SETTING '%s' (previously: '%s')" % (value, self._value)) print("SETTING '%s' (previously: '%s')" % (value, self._value))
self._value = value self._value = value
@prop.deleter
def prop(self):
print("DELETING (previously: '%s')" % self._value)
self._value = None
@my_property
def my_prop(self):
print("GETTING 'my_prop'")
return 389
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment