summaryrefslogtreecommitdiff
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2004-12-21 23:46:34 +0000
committerFred Drake <fdrake@acm.org>2004-12-21 23:46:34 +0000
commit7c404a4bf7b9061ee013bef361b6eba951218d80 (patch)
tree921da1debae9f4ac526fc818426d6ba55896bb8f /Lib/test/test_doctest.py
parente57d7b179a6171b013030c6751e8c0999251200b (diff)
downloadcpython-git-7c404a4bf7b9061ee013bef361b6eba951218d80.tar.gz
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
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 0ae6b8d180..fe4d863b97 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -2010,6 +2010,14 @@ def test_DocFileSuite():
modified the test globals. The test globals are
automatically cleared for us after a test.
+ Tests in a file run using `DocFileSuite` can also access the
+ `__file__` global, which is set to the name of the file
+ containing the tests:
+
+ >>> suite = doctest.DocFileSuite('test_doctest3.txt')
+ >>> suite.run(unittest.TestResult())
+ <unittest.TestResult run=1 errors=0 failures=0>
+
"""
def test_trailing_space_in_test():