[Python-checkins] CVS: python/dist/src/Lib/test test_inspect.py,1.4,1.5

Tim Peters tim_one@users.sourceforge.net
Fri, 21 Sep 2001 23:10:57 -0700


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

Modified Files:
	test_inspect.py 
Log Message:
Add a function to compute a class's method resolution order.  This is
easy for 2.2 new-style classes, but trickier for classic classes, and
different approaches are needed "depending".  The function will allow
later code to treat all flavors of classes uniformly.


Index: test_inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_inspect.py	2001/03/23 05:14:10	1.4
--- test_inspect.py	2001/09/22 06:10:55	1.5
***************
*** 214,215 ****
--- 214,235 ----
      except:
          pass
+ 
+ # Test classic-class method resolution order.
+ class A:    pass
+ class B(A): pass
+ class C(A): pass
+ class D(B, C): pass
+ 
+ expected = (D, B, A, C)
+ got = inspect.getmro(D)
+ test(expected == got, "expected %r mro, got %r", expected, got)
+ 
+ # The same w/ new-class MRO.
+ class A(object):    pass
+ class B(A): pass
+ class C(A): pass
+ class D(B, C): pass
+ 
+ expected = (D, B, C, A, object)
+ got = inspect.getmro(D)
+ test(expected == got, "expected %r mro, got %r", expected, got)