diff options
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 0a13d77586..2708fc7da0 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -2328,6 +2328,8 @@ def DocFileTest(path, module_relative=True, package=None, globs=None, parser=DocTestParser(), **options): if globs is None: globs = {} + else: + globs = globs.copy() if package and not module_relative: raise ValueError("Package may only be specified for module-" @@ -2337,6 +2339,8 @@ def DocFileTest(path, module_relative=True, package=None, if module_relative: package = _normalize_module(package) path = _module_relative_path(package, path) + if "__file__" not in globs: + globs["__file__"] = path # Find the file and read it. name = os.path.basename(path) |