summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-11-14 23:56:45 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-11-14 23:56:45 (GMT)
commit144b98dab82c329fc7285f4268925eba413fed3b (patch)
treee11ce0c1f8b32b53f6a61fa106248fe06872d30b /Lib
parenta91e9646e0f916498e812de467f8ac50574e22b1 (diff)
downloadcpython-144b98dab82c329fc7285f4268925eba413fed3b.zip
cpython-144b98dab82c329fc7285f4268925eba413fed3b.tar.gz
cpython-144b98dab82c329fc7285f4268925eba413fed3b.tar.bz2
More simple test cases for mixed classic+new multiple inheritance.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_descr.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index cf7ef2d..41c03a0 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -830,6 +830,34 @@ def multi():
vereq(int(Frag()), 42)
# MI mixing classic and new-style classes.
+
+ class A:
+ x = 1
+
+ class B(A):
+ pass
+
+ class C(A):
+ x = 2
+
+ class D(B, C):
+ pass
+ vereq(D.x, 1)
+
+ # Classic MRO is preserved for a classic base class.
+ class E(D, object):
+ pass
+ vereq(E.__mro__, (E, D, B, A, C, object))
+ vereq(E.x, 1)
+
+ # But with a mix of classic bases, their MROs are combined using
+ # new-style MRO.
+ class F(B, C, object):
+ pass
+ vereq(F.__mro__, (F, B, C, A, object))
+ vereq(F.x, 2)
+
+ # Try something else.
class C:
def cmethod(self):
return "C a"
@@ -875,6 +903,13 @@ def multi():
# XXX Expected this (the commented-out result):
# vereq(M3.__mro__, (M3, M1, M2, object, D, C))
vereq(M3.__mro__, (M3, M1, M2, D, C, object)) # XXX ?
+ m = M3()
+ vereq(m.cmethod(), "C a")
+ vereq(m.dmethod(), "D a")
+ vereq(m.m1method(), "M1 a")
+ vereq(m.m2method(), "M2 a")
+ vereq(m.m3method(), "M3 a")
+ vereq(m.all_method(), "M3 b")
def diamond():
if verbose: print "Testing multiple inheritance special cases..."