[Python-checkins] python/dist/src/Lib/test test_descr.py,1.149,1.150
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Thu, 01 Aug 2002 07:39:05 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv813
Modified Files:
test_descr.py
Log Message:
SF patch 588728 (Nathan Srebro).
The __delete__ method wrapper for descriptors was not supported
(I added a test, too.)
2.2 bugfix candidate.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.149
retrieving revision 1.150
diff -C2 -d -r1.149 -r1.150
*** test_descr.py 23 Jul 2002 19:03:47 -0000 1.149
--- test_descr.py 1 Aug 2002 14:39:03 -0000 1.150
***************
*** 1400,1410 ****
class C(object):
class computed_attribute(object):
! def __init__(self, get, set=None):
self.__get = get
self.__set = set
def __get__(self, obj, type=None):
return self.__get(obj)
def __set__(self, obj, value):
return self.__set(obj, value)
def __init__(self):
self.__x = 0
--- 1400,1413 ----
class C(object):
class computed_attribute(object):
! 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
***************
*** 1415,1419 ****
def __set_x(self, x):
self.__x = x
! x = computed_attribute(__get_x, __set_x)
a = C()
vereq(a.x, 0)
--- 1418,1424 ----
def __set_x(self, x):
self.__x = x
! def __delete_x(self):
! del self.__x
! x = computed_attribute(__get_x, __set_x, __delete_x)
a = C()
vereq(a.x, 0)
***************
*** 1422,1425 ****
--- 1427,1432 ----
vereq(a.x, 10)
vereq(a.x, 11)
+ del a.x
+ vereq(hasattr(a, 'x'), 0)
def newslot():
***************
*** 1734,1739 ****
C.x.__set__(a, 100)
vereq(C.x.__get__(a), 100)
! ## C.x.__set__(a)
! ## verify(not hasattr(a, "x"))
raw = C.__dict__['x']
--- 1741,1746 ----
C.x.__set__(a, 100)
vereq(C.x.__get__(a), 100)
! C.x.__delete__(a)
! verify(not hasattr(a, "x"))
raw = C.__dict__['x']