summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-24 16:55:27 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-24 16:55:27 (GMT)
commitc4a1880de49b81c05282ff62a590eb06daafca09 (patch)
tree1cd5639368d9267a164ca3feedfe8a3d937c5d0c
parentf5cb3574682b4e1bb740e99f200a4e5e585a166e (diff)
downloadcpython-c4a1880de49b81c05282ff62a590eb06daafca09.zip
cpython-c4a1880de49b81c05282ff62a590eb06daafca09.tar.gz
cpython-c4a1880de49b81c05282ff62a590eb06daafca09.tar.bz2
Add test suite for super().
-rw-r--r--Lib/test/test_descr.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 207aafe..a79353f 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1092,6 +1092,37 @@ def getsets():
## C.x.__set__(a)
## verify(not hasattr(a, "x"))
+def supers():
+ if verify: print "Testing super..."
+
+ class A(object):
+ def meth(self, a):
+ return "A(%r)" % a
+
+ verify(A().meth(1) == "A(1)")
+
+ class B(A):
+ def __init__(self):
+ self.__super = super(B, self)
+ def meth(self, a):
+ return "B(%r)" % a + self.__super.meth(a)
+
+ verify(B().meth(2) == "B(2)A(2)")
+
+ class C(A):
+ __dynamic__ = 1
+ def meth(self, a):
+ return "C(%r)" % a + self.__super.meth(a)
+ C._C__super = super(C)
+
+ verify(C().meth(3) == "C(3)A(3)")
+
+ class D(C, B):
+ def meth(self, a):
+ return "D(%r)" % a + super(D, self).meth(a)
+
+ verify (D().meth(4) == "D(4)C(4)B(4)A(4)")
+
def all():
lists()
dicts()
@@ -1122,6 +1153,7 @@ def all():
specials()
weakrefs()
getsets()
+ supers()
all()