[Python-checkins] python/dist/src/Lib/test README,1.15,1.16
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Thu, 22 Aug 2002 13:08:16 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv28357
Modified Files:
README
Log Message:
Document that docstrings are verboten for test functions.
Expand the example to show some actual test functions, and a setUp()
and tearDown() method.
Index: README
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/README,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** README 23 Jul 2002 19:13:45 -0000 1.15
--- README 22 Aug 2002 20:08:14 -0000 1.16
***************
*** 49,54 ****
underscores.
All PyUnit-based tests in the Python test suite use boilerplate that
! looks like this:
import unittest
--- 49,60 ----
underscores.
+ Test methods should *not* have docstrings! The unittest module prints
+ the docstring if there is one, but otherwise prints the function name
+ and the full class name. When there's a problem with a test, the
+ latter information makes it easier to find the source for the test
+ than the docstring.
+
All PyUnit-based tests in the Python test suite use boilerplate that
! looks like this (with minor variations):
import unittest
***************
*** 56,68 ****
class MyTestCase1(unittest.TestCase):
! # define test methods here...
class MyTestCase2(unittest.TestCase):
! # define more test methods here...
def test_main():
! suite = unittest.TestSuite()
! suite.addTest(unittest.makeSuite(MyTestCase1))
! suite.addTest(unittest.makeSuite(MyTestCase2))
test_support.run_suite(suite)
--- 62,96 ----
class MyTestCase1(unittest.TestCase):
!
! # Define setUp and tearDown only if needed
!
! def setUp(self):
! unittest.TestCase.setUp(self)
! ... additional initialization...
!
! def tearDown(self):
! ... additional finalization...
! unittest.TestCase.tearDown(self)
!
! def test_feature_one(self):
! # Testing feature one
! ...unit test for feature one...
!
! def test_feature_two(self):
! # Testing feature two
! ...unit test for feature two...
!
! ...etc...
class MyTestCase2(unittest.TestCase):
! ...same structure as MyTestCase1...
!
! ...etc...
def test_main():
! suite = unittest.TestSuite()
! suite.addTest(unittest.makeSuite(MyTestCase1))
! suite.addTest(unittest.makeSuite(MyTestCase2))
! ...add more suites...
test_support.run_suite(suite)