aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_threads.py
diff options
context:
space:
mode:
authorLoïc Estève <loic.esteve@ymail.com>2024-09-13 20:13:30 +0200
committerGitHub <noreply@github.com>2024-09-13 11:13:30 -0700
commiteadb9660ed836b40667d4f662eae90287ff18397 (patch)
tree68fd2ee7a4c803d0eef76df53e92719dce44b668 /Lib/test/test_asyncio/test_threads.py
parent9f42b62db998131bb5cd555e2fa72ba7e06e3130 (diff)
downloadcpython-eadb9660ed836b40667d4f662eae90287ff18397.tar.gz
cpython-eadb9660ed836b40667d4f662eae90287ff18397.zip
gh-122957: Fix test flakiness in asyncio test in free-thread build (#124039)
Diffstat (limited to 'Lib/test/test_asyncio/test_threads.py')
-rw-r--r--Lib/test/test_asyncio/test_threads.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_asyncio/test_threads.py b/Lib/test/test_asyncio/test_threads.py
index 1138a93e0f7..774380270a7 100644
--- a/Lib/test/test_asyncio/test_threads.py
+++ b/Lib/test/test_asyncio/test_threads.py
@@ -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.