[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.102,1.103

Tim Peters tim_one@users.sourceforge.net
Wed, 14 Nov 2001 15:32:35 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv8578/python/Lib/test

Modified Files:
	test_descr.py 
Log Message:
Changing diapers reminded Guido that he wanted to allow for some measure
of multiple inheritance from a mix of new- and classic-style classes.
This is his patch, plus a start at some test cases from me.  Will check
in more, plus a NEWS blurb, later tonight.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.102
retrieving revision 1.103
diff -C2 -d -r1.102 -r1.103
*** test_descr.py	2001/10/30 23:20:46	1.102
--- test_descr.py	2001/11/14 23:32:33	1.103
***************
*** 830,833 ****
--- 830,880 ----
      vereq(int(Frag()), 42)
  
+     # MI mixing classic and new-style classes.
+     class C:
+         def cmethod(self):
+             return "C a"
+         def all_method(self):
+             return "C b"
+ 
+     class M1(C, object):
+         def m1method(self):
+             return "M1 a"
+         def all_method(self):
+             return "M1 b"
+ 
+     vereq(M1.__mro__, (M1, C, object))
+     m = M1()
+     vereq(m.cmethod(), "C a")
+     vereq(m.m1method(), "M1 a")
+     vereq(m.all_method(), "M1 b")
+ 
+     class D(C):
+         def dmethod(self):
+             return "D a"
+         def all_method(self):
+             return "D b"
+ 
+     class M2(object, D):
+         def m2method(self):
+             return "M2 a"
+         def all_method(self):
+             return "M2 b"
+ 
+     vereq(M2.__mro__, (M2, object, D, C))
+     m = M2()
+     vereq(m.cmethod(), "C a")
+     vereq(m.dmethod(), "D a")
+     vereq(m.m2method(), "M2 a")
+     vereq(m.all_method(), "M2 b")
+ 
+     class M3(M1, object, M2):
+         def m3method(self):
+             return "M3 a"
+         def all_method(self):
+             return "M3 b"
+     # 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 ?
+ 
  def diamond():
      if verbose: print "Testing multiple inheritance special cases..."
***************
*** 1016,1027 ****
      class Classic:
          pass
- 
-     try:
-         class C(object, Classic):
-             pass
-     except TypeError:
-         pass
-     else:
-         verify(0, "inheritance from object and Classic should be illegal")
  
      try:
--- 1063,1066 ----