[Python-checkins] python/dist/src/Lib doctest.py,1.120,1.121

fdrake at users.sourceforge.net fdrake at users.sourceforge.net
Wed Dec 22 00:46:59 CET 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22743/Lib

Modified Files:
	doctest.py 
Log Message:
add __file__ to the globals available for tests loaded via DocFileSuite;
this is useful for locating supporting data files, just as it is in Python
modules


Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- doctest.py	8 Nov 2004 22:31:09 -0000	1.120
+++ doctest.py	21 Dec 2004 23:46:24 -0000	1.121
@@ -2328,6 +2328,8 @@
                 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 @@
     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)



More information about the Python-checkins mailing list