mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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
This commit is contained in:
parent
e57d7b179a
commit
7c404a4bf7
4 changed files with 21 additions and 0 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue