summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-24 15:24:24 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-24 15:24:24 (GMT)
commit76f0cb85c2269e61a8e31c1d5133975ecef3ec70 (patch)
tree5b2b3790c6568742e0398716ff83eeaf5f11bc9e /Lib/test
parent271410ad189d9482274a4acba44ae29059ae2b55 (diff)
downloadcpython-76f0cb85c2269e61a8e31c1d5133975ecef3ec70.zip
cpython-76f0cb85c2269e61a8e31c1d5133975ecef3ec70.tar.gz
cpython-76f0cb85c2269e61a8e31c1d5133975ecef3ec70.tar.bz2
Add a test for the new getset type.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_descr.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index b26f165..207aafe 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1069,6 +1069,29 @@ def weakrefs():
verify(r() is None)
del r
+def getsets():
+ if verbose: print "Testing getset..."
+ class C(object):
+ def getx(self):
+ return self.__x
+ def setx(self, value):
+ self.__x = value
+ def delx(self):
+ del self.__x
+ x = getset(getx, setx, delx)
+ a = C()
+ verify(not hasattr(a, "x"))
+ a.x = 42
+ verify(a._C__x == 42)
+ verify(a.x == 42)
+ del a.x
+ verify(not hasattr(a, "x"))
+ verify(not hasattr(a, "_C__x"))
+ C.x.__set__(a, 100)
+ verify(C.x.__get__(a) == 100)
+## C.x.__set__(a)
+## verify(not hasattr(a, "x"))
+
def all():
lists()
dicts()
@@ -1098,6 +1121,7 @@ def all():
methods()
specials()
weakrefs()
+ getsets()
all()