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

Guido van Rossum gvanrossum@users.sourceforge.net
2001年6月05日 18:03:16 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv16053
Modified Files:
 Tag: descr-branch
	test_descr.py 
Log Message:
Testing __metaclass__ and multiple inheritance (for mix-ins).
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/Attic/test_descr.py,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -C2 -r1.1.2.10 -r1.1.2.11
*** test_descr.py	2001年06月05日 10:49:24	1.1.2.10
--- test_descr.py	2001年06月06日 01:03:14	1.1.2.11
***************
*** 339,342 ****
--- 339,370 ----
 ("delattr", "foo")], log)
 
+ def baseless():
+ if verbose: print "Testing __metaclass__ and mix-ins..."
+ global C
+ class C:
+ __metaclass__ = type(type(0))
+ def __init__(self):
+ self.__state = 0
+ def getstate(self):
+ return self.__state
+ def setstate(self, state):
+ self.__state = state
+ a = C()
+ verify(a.getstate() == 0)
+ a.setstate(10)
+ verify(a.getstate() == 10)
+ class D(type({}), C):
+ def __init__(self):
+ type({}).__init__(self)
+ C.__init__(self)
+ d = D()
+ verify(d.keys() == [])
+ d["hello"] = "world"
+ verify(d.items() == [("hello", "world")])
+ verify(d["hello"] == "world")
+ verify(d.getstate() == 0)
+ d.setstate(10)
+ verify(d.getstate() == 10)
+ 
 def all():
 lists()
***************
*** 349,352 ****
--- 377,381 ----
 pydicts()
 pymods()
+ baseless()
 
 all()

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