Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ca5374

Browse files
committed
Rewrote the PyUnit description so that it now recommends to use
run_suite() instead of run_unittest(). Best practice is to plan for multiple test classes.
1 parent 99d1700 commit 5ca5374

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

Lib/test/README

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,31 @@ The test_support helper module provides a two functions for use by
4040
PyUnit based tests in the Python regression testing framework:
4141
run_unittest() takes a unittest.TestCase derived class as a parameter
4242
and runs the tests defined in that class, and run_suite() takes a
43-
populated TestSuite instance and runs the tests.. All test methods in
44-
the Python regression framework have names that start with "test_" and
45-
use lower-case names with words separated with underscores.
43+
populated TestSuite instance and runs the tests. run_suite() is
44+
preferred because unittest files typically grow multiple test classes,
45+
and you might as well be prepared.
46+
47+
All test methods in the Python regression framework have names that
48+
start with "test_" and use lower-case names with words separated with
49+
underscores.
4650

4751
All PyUnit-based tests in the Python test suite use boilerplate that
4852
looks like this:
4953

5054
import unittest
5155
import test_support
5256

53-
class MyTestCase(unittest.TestCase):
57+
class MyTestCase1(unittest.TestCase):
5458
# define test methods here...
5559

60+
class MyTestCase2(unittest.TestCase):
61+
# define more test methods here...
62+
5663
def test_main():
57-
test_support.run_unittest(MyTestCase)
64+
suite = unittest.TestSuite()
65+
suite.addTest(unittest.makeSuite(MyTestCase1))
66+
suite.addTest(unittest.makeSuite(MyTestCase2))
67+
test_support.run_suite(suite)
5868

5969
if __name__ == "__main__":
6070
test_main()
@@ -153,7 +163,7 @@ top level:
153163

154164
make test
155165

156-
{WINDOWS] Run rt.bat from your PCBuild directory. Read the comments at
166+
[WINDOWS] Run rt.bat from your PCBuild directory. Read the comments at
157167
the top of rt.bat for the use of special -d, -O and -q options processed
158168
by rt.bat.
159169

0 commit comments

Comments
 (0)