@@ -1044,12 +1044,13 @@ def __runone(self, target, name):
10441044
10451045master = None
10461046
1047- def testmod (m , name = None , globs = None , verbose = None , isprivate = None ,
1047+ def testmod (m = None , name = None , globs = None , verbose = None , isprivate = None ,
10481048 report = 1 ):
1049- """m, name=None, globs=None, verbose=None, isprivate=None, report=1
1049+ """m=None , name=None, globs=None, verbose=None, isprivate=None, report=1
10501050
1051- Test examples in docstrings in functions and classes reachable from
1052- module m, starting with m.__doc__. Private names are skipped.
1051+ Test examples in docstrings in functions and classes reachable
1052+ from module m (or the current module if m is not supplied), starting
1053+ with m.__doc__. Private names are skipped.
10531054
10541055 Also test examples reachable from dict m.__test__ if it exists and is
10551056 not None. m.__dict__ maps names to functions, classes and strings;
@@ -1090,6 +1091,13 @@ class doctest.Tester, then merges the results into (or creates)
10901091
10911092 global master
10921093
1094+ if m is None :
1095+ import sys
1096+ # DWA - m will still be None if this wasn't invoked from the command
1097+ # line, in which case the following TypeError is about as good an error
1098+ # as we should expect
1099+ m = sys .modules .get ('__main__' )
1100+
10931101 if not _ismodule (m ):
10941102 raise TypeError ("testmod: module required; " + `m` )
10951103 if name is None :
0 commit comments