diff options
| author | Raymond Hettinger <python@rcn.com> | 2009-01-27 10:30:26 (GMT) |
|---|---|---|
| committer | Raymond Hettinger <python@rcn.com> | 2009-01-27 10:30:26 (GMT) |
| commit | 8c0cee814fc0c4527ad39dc430802c331a804760 (patch) | |
| tree | c7abdd7a663c35d7d39fd9e53f0b189e0cca4262 /Lib/doctest.py | |
| parent | cdc9f2c1d573a4ae96ac592c303f7f443a704859 (diff) | |
| download | cpython-8c0cee814fc0c4527ad39dc430802c331a804760.zip cpython-8c0cee814fc0c4527ad39dc430802c331a804760.tar.gz cpython-8c0cee814fc0c4527ad39dc430802c331a804760.tar.bz2 | |
Issue 5021: doctest.testfile should set __name__
Diffstat (limited to 'Lib/doctest.py')
| -rw-r--r-- | Lib/doctest.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index 3f2baa5..aeeb15d 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -844,6 +844,8 @@ class DocTestFinder: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) + if '__name__' not in globs: + globs['__name__'] = '__main__' # provide a default module name # Recursively expore `obj`, extracting DocTests. tests = [] @@ -1937,6 +1939,8 @@ def testfile(filename, module_relative=True, name=None, package=None, globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) + if '__name__' not in globs: + globs['__name__'] = '__main__' if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) |
