[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.20,1.21
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 24 Aug 2001 09:55:29 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv23288
Modified Files:
test_descr.py
Log Message:
Add test suite for super().
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** test_descr.py 2001/08/24 15:24:24 1.20
--- test_descr.py 2001/08/24 16:55:27 1.21
***************
*** 1093,1096 ****
--- 1093,1127 ----
## 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()
***************
*** 1123,1126 ****
--- 1154,1158 ----
weakrefs()
getsets()
+ supers()
all()