diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-03-13 14:16:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-13 14:16:23 (GMT) |
commit | 283dda83ec37e3d5466ef4561a38172374307740 (patch) | |
tree | 61d349fc121c8f9f4de8a5b74d799d36c956f194 /Lib | |
parent | 89b5c5e321d84dfe5716b5b7eaa5dbda497301be (diff) | |
download | cpython-283dda83ec37e3d5466ef4561a38172374307740.zip cpython-283dda83ec37e3d5466ef4561a38172374307740.tar.gz cpython-283dda83ec37e3d5466ef4561a38172374307740.tar.bz2 |
[3.12] gh-110918: Fix side effects of regrtest test_match_tests() (GH-116718) (#116726)
gh-110918: Fix side effects of regrtest test_match_tests() (GH-116718)
test_match_tests now saves and restores patterns.
Add get_match_tests() function to libregrtest.filter.
Previously, running test_regrtest multiple times in a row only ran
tests once: "./python -m test test_regrtest -R 3:3.
(cherry picked from commit 612f1ec988314bc0bc42a1b908751950331e2ede)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/libregrtest/filter.py | 5 | ||||
-rw-r--r-- | Lib/test/test_regrtest.py | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/libregrtest/filter.py b/Lib/test/libregrtest/filter.py index 817624d..41372e4 100644 --- a/Lib/test/libregrtest/filter.py +++ b/Lib/test/libregrtest/filter.py @@ -27,6 +27,11 @@ def _is_full_match_test(pattern): return ('.' in pattern) and (not re.search(r'[?*\[\]]', pattern)) +def get_match_tests(): + global _test_patterns + return _test_patterns + + def set_match_tests(patterns): global _test_matchers, _test_patterns diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 2ab6f6a..08b3f14 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -27,7 +27,7 @@ from test.libregrtest import cmdline from test.libregrtest import main from test.libregrtest import setup from test.libregrtest import utils -from test.libregrtest.filter import set_match_tests, match_test +from test.libregrtest.filter import get_match_tests, set_match_tests, match_test from test.libregrtest.result import TestStats from test.libregrtest.utils import normalize_test_name @@ -2234,6 +2234,10 @@ class TestUtils(unittest.TestCase): def id(self): return self.test_id + # Restore patterns once the test completes + patterns = get_match_tests() + self.addCleanup(set_match_tests, patterns) + test_access = Test('test.test_os.FileTests.test_access') test_chdir = Test('test.test_os.Win32ErrorTests.test_chdir') test_copy = Test('test.test_shutil.TestCopy.test_copy') |