summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2024-04-03 14:17:13 (GMT)
committerGitHub <noreply@github.com>2024-04-03 14:17:13 (GMT)
commitfc5f68e58ecfbc8c452e1c2f33a2a53d3f2d7ea2 (patch)
tree0138ade12916a1453a5cf316b5176984ee1ca867 /Lib/unittest
parentea94b3b149eeadf33c2f7c46f16dcda0adc7cf4e (diff)
downloadcpython-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 'Lib/unittest')
-rw-r--r--Lib/unittest/loader.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py
index 9a3e5cc..22797b8 100644
--- a/Lib/unittest/loader.py
+++ b/Lib/unittest/loader.py
@@ -254,6 +254,7 @@ class TestLoader(object):
Paths are sorted before being imported to ensure reproducible execution
order even on filesystems with non-alphabetical ordering like ext3/4.
"""
+ original_top_level_dir = self._top_level_dir
set_implicit_top = False
if top_level_dir is None and self._top_level_dir is not None:
# make top_level_dir optional if called from load_tests in a package
@@ -307,6 +308,7 @@ class TestLoader(object):
raise ImportError('Start directory is not importable: %r' % start_dir)
tests = list(self._find_tests(start_dir, pattern))
+ self._top_level_dir = original_top_level_dir
return self.suiteClass(tests)
def _get_directory_containing_module(self, module_name):