diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2002-11-22 08:23:09 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2002-11-22 08:23:09 (GMT) |
commit | 4581cfa326cf7d8b9d7888d4c0e96ee88950bcfa (patch) | |
tree | 1dafb4db99d1068c86f3470af1a2a2173315d273 /Lib/doctest.py | |
parent | f86e8ef33ec22475a051b783b19ee22c5bd3de72 (diff) | |
download | cpython-4581cfa326cf7d8b9d7888d4c0e96ee88950bcfa.zip cpython-4581cfa326cf7d8b9d7888d4c0e96ee88950bcfa.tar.gz cpython-4581cfa326cf7d8b9d7888d4c0e96ee88950bcfa.tar.bz2 |
Patch #486438: Make module argument to testmod optional.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index 5cbdd06..c01606d 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -1044,12 +1044,13 @@ see its docs for details. master = None -def testmod(m, name=None, globs=None, verbose=None, isprivate=None, +def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None, report=1): - """m, name=None, globs=None, verbose=None, isprivate=None, report=1 + """m=None, name=None, globs=None, verbose=None, isprivate=None, report=1 - Test examples in docstrings in functions and classes reachable from - module m, starting with m.__doc__. Private names are skipped. + Test examples in docstrings in functions and classes reachable + from module m (or the current module if m is not supplied), starting + with m.__doc__. Private names are skipped. Also test examples reachable from dict m.__test__ if it exists and is not None. m.__dict__ maps names to functions, classes and strings; @@ -1090,6 +1091,13 @@ def testmod(m, name=None, globs=None, verbose=None, isprivate=None, global master + if m is None: + import sys + # DWA - m will still be None if this wasn't invoked from the command + # line, in which case the following TypeError is about as good an error + # as we should expect + m = sys.modules.get('__main__') + if not _ismodule(m): raise TypeError("testmod: module required; " + `m`) if name is None: |