diff options
author | Barry Warsaw <barry@python.org> | 2002-04-23 21:39:00 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-04-23 21:39:00 (GMT) |
commit | 5ca537473b5840241aac613724e7557a216e0458 (patch) | |
tree | 69c1b57847f5bfecdd87859ce3e127058851a0c6 /Lib/test/README | |
parent | 99d17006c12d2e768a7b8e1c706adf6b4e152140 (diff) | |
download | cpython-5ca537473b5840241aac613724e7557a216e0458.zip cpython-5ca537473b5840241aac613724e7557a216e0458.tar.gz cpython-5ca537473b5840241aac613724e7557a216e0458.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/README')
-rw-r--r-- | Lib/test/README | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Lib/test/README b/Lib/test/README index 455b365..0aa2b1e 100644 --- a/Lib/test/README +++ b/Lib/test/README @@ -40,9 +40,13 @@ The test_support helper module provides a two functions for use by PyUnit based tests in the Python regression testing framework: run_unittest() takes a unittest.TestCase derived class as a parameter and runs the tests defined in that class, and run_suite() takes a -populated TestSuite instance and runs the tests.. All test methods in -the Python regression framework have names that start with "test_" and -use lower-case names with words separated with underscores. +populated TestSuite instance and runs the tests. run_suite() is +preferred because unittest files typically grow multiple test classes, +and you might as well be prepared. + +All test methods in the Python regression framework have names that +start with "test_" and use lower-case names with words separated with +underscores. All PyUnit-based tests in the Python test suite use boilerplate that looks like this: @@ -50,11 +54,17 @@ looks like this: import unittest import test_support - class MyTestCase(unittest.TestCase): + class MyTestCase1(unittest.TestCase): # define test methods here... + class MyTestCase2(unittest.TestCase): + # define more test methods here... + def test_main(): - test_support.run_unittest(MyTestCase) + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(MyTestCase1)) + suite.addTest(unittest.makeSuite(MyTestCase2)) + test_support.run_suite(suite) if __name__ == "__main__": test_main() @@ -153,7 +163,7 @@ top level: make test -{WINDOWS] Run rt.bat from your PCBuild directory. Read the comments at +[WINDOWS] Run rt.bat from your PCBuild directory. Read the comments at the top of rt.bat for the use of special -d, -O and -q options processed by rt.bat. |