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

Guido van Rossum gvanrossum@users.sourceforge.net
2001年7月05日 14:42:39 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv26606
Modified Files:
 Tag: descr-branch
	test_descr.py 
Log Message:
Add some tests for mro() and overriding mro().
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/Attic/test_descr.py,v
retrieving revision 1.1.2.28
retrieving revision 1.1.2.29
diff -C2 -r1.1.2.28 -r1.1.2.29
*** test_descr.py	2001年07月05日 21:33:01	1.1.2.28
--- test_descr.py	2001年07月05日 21:42:37	1.1.2.29
***************
*** 716,719 ****
--- 716,742 ----
 verify(b.__class__ is D)
 
+ class PerverseMetaType(type):
+ def mro(cls):
+ L = type.mro(cls)
+ L.reverse()
+ return L
+ 
+ def altmro():
+ if verbose: print "Testing mro() and overriding it..."
+ class A(object):
+ def f(self): return "A"
+ class B(A):
+ pass
+ class C(A):
+ def f(self): return "C"
+ class D(B, C):
+ pass
+ verify(D.mro() == [D, B, C, A, object] == list(D.__mro__))
+ verify(D().f() == "C")
+ class X(A,B,C,D):
+ __metaclass__ = PerverseMetaType
+ verify(X.__mro__ == (object, A, C, B, D, X))
+ verify(X().f() == "A")
+ 
 def all():
 lists()
***************
*** 740,743 ****
--- 763,767 ----
 compattr()
 newslot()
+ altmro()
 
 all()

AltStyle によって変換されたページ (->オリジナル) /