[Python-checkins] CVS: python/dist/src/Lib/test test_copy_reg.py,1.1,1.2
Fred L. Drake
fdrake@users.sourceforge.net
2001年5月22日 13:38:46 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv30348
Modified Files:
test_copy_reg.py
Log Message:
Convert copy_reg test to PyUnit.
Index: test_copy_reg.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_copy_reg.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** test_copy_reg.py 2000年10月11日 22:17:35 1.1
--- test_copy_reg.py 2001年05月22日 20:38:44 1.2
***************
*** 1,35 ****
import copy_reg
class C:
pass
! try:
! copy_reg.pickle(C, None, None)
! except TypeError, e:
! print "Caught expected TypeError:"
! print e
! else:
! print "Failed to catch expected TypeError when registering a class type."
!
!
! print
! try:
! copy_reg.pickle(type(1), "not a callable")
! except TypeError, e:
! print "Caught expected TypeError:"
! print e
! else:
! print "Failed to catch TypeError " \
! "when registering a non-callable reduction function."
!
!
! print
! try:
! copy_reg.pickle(type(1), int, "not a callable")
! except TypeError, e:
! print "Caught expected TypeError:"
! print e
! else:
! print "Failed to catch TypeError " \
! "when registering a non-callable constructor."
--- 1,25 ----
import copy_reg
+ import test_support
+ import unittest
+
class C:
pass
+
+ class CopyRegTestCase(unittest.TestCase):
+
+ def test_class(self):
+ self.assertRaises(TypeError, copy_reg.pickle,
+ C, None, None)
+
+ def test_noncallable_reduce(self):
+ self.assertRaises(TypeError, copy_reg.pickle,
+ type(1), "not a callable")
+
+ def test_noncallable_constructor(self):
+ self.assertRaises(TypeError, copy_reg.pickle,
+ type(1), int, "not a callable")
+
! test_support.run_unittest(CopyRegTestCase)