summaryrefslogtreecommitdiffstats
path: root/Lib/test/README
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-09 06:12:01 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-09 06:12:01 (GMT)
commita0a62225094a890c1b07ebc4f89e4c7c45c66b13 (patch)
tree147057adad1ae5b6548b708753a2febe91080d5f /Lib/test/README
parent90ba8d9c80c4eba418ca2ddaefbf59c4acf00cf3 (diff)
downloadcpython-a0a62225094a890c1b07ebc4f89e4c7c45c66b13.zip
cpython-a0a62225094a890c1b07ebc4f89e4c7c45c66b13.tar.gz
cpython-a0a62225094a890c1b07ebc4f89e4c7c45c66b13.tar.bz2
Teach regrtest how to pass on doctest failure msgs. This is done via a
horridly inefficient hack in regrtest's Compare class, but it's about as clean as can be: regrtest has to set up the Compare instance before importing a test module, and by the time the module *is* imported it's too late to change that decision. The good news is that the more tests we convert to unittest and doctest, the less the inefficiency here matters. Even now there are few tests with large expected-output files (the new cost here is a Python-level call per .write() when there's an expected- output file).
Diffstat (limited to 'Lib/test/README')
-rw-r--r--Lib/test/README28
1 files changed, 23 insertions, 5 deletions
diff --git a/Lib/test/README b/Lib/test/README
index 0a663e0..4850957 100644
--- a/Lib/test/README
+++ b/Lib/test/README
@@ -55,14 +55,32 @@ The module in the test package is simply a wrapper that causes doctest
to run over the tests in the module. The test for the difflib module
provides a convenient example:
- from test_support import verbose
- import doctest, difflib
- doctest.testmod(difflib, verbose=verbose)
+ import difflib, test_support
+ test_support.run_doctest(difflib)
If the test is successful, nothing is written to stdout (so you should not
create a corresponding output/test_difflib file), but running regrtest
-with -v will give a detailed report, the same as if passing -v to doctest
-(that's what importing verbose from test_support accomplishes).
+with -v will give a detailed report, the same as if passing -v to doctest.
+
+A second argument can be passed to run_doctest to tell doctest to search
+sys.argv for -v instead of using test_support's idea of verbosity. This
+is useful for writing doctest-based tests that aren't simply running a
+doctest'ed Lib module, but contain the doctests themselves. Then at
+times you may want to run such a test directly as a doctest, independent
+of the regrtest framework. The tail end of test_descrtut.py is a good
+example:
+
+ def test_main(verbose=None):
+ import test_support, test.test_descrtut
+ test_support.run_doctest(test.test_descrtut, verbose)
+
+ if __name__ == "__main__":
+ test_main(1)
+
+If run via regrtest, test_main() is called (by regrtest) without specifying
+verbose, and then test_supprot's idea of verbosity is used. But when
+run directly, test_main(1) is called, and then doctest's idea of verbosity
+is used.
See the documentation for the doctest module for information on
writing tests using the doctest framework.