]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-122957: Fix test flakiness in asyncio test in free-thread build (#124039)
authorLoïc Estève <loic.esteve@ymail.com>
Fri, 13 Sep 2024 18:13:30 +0000 (20:13 +0200)
committerGitHub <noreply@github.com>
Fri, 13 Sep 2024 18:13:30 +0000 (11:13 -0700)
Lib/test/test_asyncio/test_threads.py

index 1138a93e0f78ec658903d060fcdfcde3dee5722b..774380270a7d70a212ecb4c77353f18ed19cbfbb 100644 (file)
@@ -30,7 +30,9 @@ class ToThreadTests(unittest.IsolatedAsyncioTestCase):
         func.assert_called_once()
 
     async def test_to_thread_concurrent(self):
-        func = mock.Mock()
+        calls = []
+        def func():
+            calls.append(1)
 
         futs = []
         for _ in range(10):
@@ -38,7 +40,7 @@ class ToThreadTests(unittest.IsolatedAsyncioTestCase):
             futs.append(fut)
         await asyncio.gather(*futs)
 
-        self.assertEqual(func.call_count, 10)
+        self.assertEqual(sum(calls), 10)
 
     async def test_to_thread_args_kwargs(self):
         # Unlike run_in_executor(), to_thread() should directly accept kwargs.