From: Sam Gross Date: Mon, 24 Mar 2025 20:41:50 +0000 (-0400) Subject: gh-131677: Fix flaky test_lru_cache_threaded3 (gh-131679) X-Git-Tag: v3.14.0a7~203 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1232459860235f4fb7896cc95966d87a51cbe32;p=thirdparty%2FPython%2Fcpython.git gh-131677: Fix flaky test_lru_cache_threaded3 (gh-131679) The call to `with self.subTest(...)` was not thread-safe. --- diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 0bbfcfd0369c..2b49615178f1 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -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):