summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-01 14:39:25 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-01 14:39:25 (GMT)
commit0dbab4c560c944956e4b732fe33ba0d72a8fb6df (patch)
tree27dc56338afbf753f5f13e2e74d68f89becf323f /Lib/test/test_descr.py
parent74824584ef6358eed6fe56cf5513fec5ad9da0da (diff)
downloadcpython-0dbab4c560c944956e4b732fe33ba0d72a8fb6df.zip
cpython-0dbab4c560c944956e4b732fe33ba0d72a8fb6df.tar.gz
cpython-0dbab4c560c944956e4b732fe33ba0d72a8fb6df.tar.bz2
SF patch 588728 (Nathan Srebro).
The __delete__ method wrapper for descriptors was not supported (I added a test, too.) 2.2 bugfix candidate.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 1dfc5ab..543dfa4 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1399,13 +1399,16 @@ def compattr():
if verbose: print "Testing computed attributes..."
class C(object):
class computed_attribute(object):
- def __init__(self, get, set=None):
+ def __init__(self, get, set=None, delete=None):
self.__get = get
self.__set = set
+ self.__delete = delete
def __get__(self, obj, type=None):
return self.__get(obj)
def __set__(self, obj, value):
return self.__set(obj, value)
+ def __delete__(self, obj):
+ return self.__delete(obj)
def __init__(self):
self.__x = 0
def __get_x(self):
@@ -1414,13 +1417,17 @@ def compattr():
return x
def __set_x(self, x):
self.__x = x
- x = computed_attribute(__get_x, __set_x)
+ def __delete_x(self):
+ del self.__x
+ x = computed_attribute(__get_x, __set_x, __delete_x)
a = C()
vereq(a.x, 0)
vereq(a.x, 1)
a.x = 10
vereq(a.x, 10)
vereq(a.x, 11)
+ del a.x
+ vereq(hasattr(a, 'x'), 0)
def newslot():
if verbose: print "Testing __new__ slot override..."
@@ -1733,8 +1740,8 @@ def properties():
verify(not hasattr(a, "_C__x"))
C.x.__set__(a, 100)
vereq(C.x.__get__(a), 100)
-## C.x.__set__(a)
-## verify(not hasattr(a, "x"))
+ C.x.__delete__(a)
+ verify(not hasattr(a, "x"))
raw = C.__dict__['x']
verify(isinstance(raw, property))