]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131677: Fix flaky test_lru_cache_threaded3 (gh-131679)
authorSam Gross <colesbury@gmail.com>
Mon, 24 Mar 2025 20:41:50 +0000 (16:41 -0400)
committerGitHub <noreply@github.com>
Mon, 24 Mar 2025 20:41:50 +0000 (16:41 -0400)
The call to `with self.subTest(...)` was not thread-safe.

Lib/test/test_functools.py

index 0bbfcfd0369cf3e27ef10b8f0537d5ab68adf59e..2b49615178f13660a7b9a45fae1fbf15b27eaee1 100644 (file)
@@ -1934,8 +1934,7 @@ class TestLRU:
             time.sleep(.01)
             return 3 * x
         def test(i, x):
-            with self.subTest(thread=i):
-                self.assertEqual(f(x), 3 * x, i)
+            self.assertEqual(f(x), 3 * x, i)
         threads = [threading.Thread(target=test, args=(i, v))
                    for i, v in enumerate([1, 2, 2, 3, 2])]
         with threading_helper.start_threads(threads):