[Python-checkins] python/dist/src/Lib doctest.py,1.113,1.114
edloper at users.sourceforge.net
edloper at users.sourceforge.net
Mon Sep 27 05:43:01 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30397/Lib
Modified Files:
doctest.py
Log Message:
- Added a "parser" option to testfile() and DocFileTest().
Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- doctest.py 26 Sep 2004 03:50:06 -0000 1.113
+++ doctest.py 27 Sep 2004 03:42:58 -0000 1.114
@@ -1852,7 +1852,7 @@
def testfile(filename, module_relative=True, name=None, package=None,
globs=None, verbose=None, report=True, optionflags=0,
- extraglobs=None, raise_on_error=False):
+ extraglobs=None, raise_on_error=False, parser=DocTestParser()):
"""
Test examples in the given file. Return (#failures, #tests).
@@ -1914,6 +1914,9 @@
first unexpected exception or failure. This allows failures to be
post-mortem debugged.
+ Optional keyword arg "parser" specifies a DocTestParser (or
+ subclass) that should be used to extract tests from the files.
+
Advanced tomfoolery: testmod runs methods of a local instance of
class doctest.Tester, then merges the results into (or creates)
global Tester instance doctest.master. Methods of doctest.master
@@ -1952,7 +1955,7 @@
# Read the file, convert it to a test, and run it.
s = open(filename).read()
- test = DocTestParser().get_doctest(s, globs, name, filename, 0)
+ test = parser.get_doctest(s, globs, name, filename, 0)
runner.run(test)
if report:
@@ -2321,7 +2324,7 @@
)
def DocFileTest(path, module_relative=True, package=None,
- globs=None, **options):
+ globs=None, parser=DocTestParser(), **options):
if globs is None:
globs = {}
@@ -2339,7 +2342,7 @@
doc = open(path).read()
# Convert it to a test, and wrap it in a DocFileCase.
- test = DocTestParser().get_doctest(doc, globs, name, path, 0)
+ test = parser.get_doctest(doc, globs, name, path, 0)
return DocFileCase(test, **options)
def DocFileSuite(*paths, **kw):
@@ -2389,7 +2392,11 @@
A dictionary containing initial global variables for the tests.
optionflags
- A set of doctest option flags expressed as an integer.
+ A set of doctest option flags expressed as an integer.
+
+ parser
+ A DocTestParser (or subclass) that should be used to extract
+ tests from the files.
"""
suite = unittest.TestSuite()
More information about the Python-checkins
mailing list