diff options
author | Raymond Hettinger <python@rcn.com> | 2009-01-27 10:06:09 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-01-27 10:06:09 (GMT) |
commit | 0f05517d85efcce6fc57cec63ec54a4612ee5382 (patch) | |
tree | 9bdba0b7260d9c587f0ab69d12c6e89cf72396e6 /Lib/doctest.py | |
parent | d17ad8d6386c446763554d61d777ee65ea68e97a (diff) | |
download | cpython-0f05517d85efcce6fc57cec63ec54a4612ee5382.zip cpython-0f05517d85efcce6fc57cec63ec54a4612ee5382.tar.gz cpython-0f05517d85efcce6fc57cec63ec54a4612ee5382.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 74ae795..5fa588d 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -837,6 +837,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 = [] @@ -1947,6 +1949,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) |