diff options
author | Zackery Spytz <zspytz@gmail.com> | 2024-04-03 14:17:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 14:17:13 (GMT) |
commit | fc5f68e58ecfbc8c452e1c2f33a2a53d3f2d7ea2 (patch) | |
tree | 0138ade12916a1453a5cf316b5176984ee1ca867 /Doc | |
parent | ea94b3b149eeadf33c2f7c46f16dcda0adc7cf4e (diff) | |
download | cpython-fc5f68e58ecfbc8c452e1c2f33a2a53d3f2d7ea2.zip cpython-fc5f68e58ecfbc8c452e1c2f33a2a53d3f2d7ea2.tar.gz cpython-fc5f68e58ecfbc8c452e1c2f33a2a53d3f2d7ea2.tar.bz2 |
gh-59215: unittest: restore _top_level_dir at end of discovery (GH-15242)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/unittest.rst | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index e6140ac..3af29f1 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -1880,8 +1880,8 @@ Loading and running tests Python identifiers) will be loaded. All test modules must be importable from the top level of the project. If - the start directory is not the top level directory then the top level - directory must be specified separately. + the start directory is not the top level directory then *top_level_dir* + must be specified separately. If importing a module fails, for example due to a syntax error, then this will be recorded as a single error and discovery will continue. If @@ -1901,9 +1901,11 @@ Loading and running tests package. The pattern is deliberately not stored as a loader attribute so that - packages can continue discovery themselves. *top_level_dir* is stored so - ``load_tests`` does not need to pass this argument in to - ``loader.discover()``. + packages can continue discovery themselves. + + *top_level_dir* is stored internally, and used as a default to any + nested calls to ``discover()``. That is, if a package's ``load_tests`` + calls ``loader.discover()``, it does not need to pass this argument. *start_dir* can be a dotted module name as well as a directory. @@ -1930,6 +1932,9 @@ Loading and running tests *start_dir* can not be a :term:`namespace packages <namespace package>`. It has been broken since Python 3.7 and Python 3.11 officially remove it. + .. versionchanged:: 3.13 + *top_level_dir* is only stored for the duration of *discover* call. + The following attributes of a :class:`TestLoader` can be configured either by subclassing or assignment on an instance: |