From e61563371cf92343cc9ac60ff79eec9b27d8f155 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Fri, 23 Jan 2026 06:31:59 +0100 Subject: [PATCH] tests: asyncio: collect garbage in run_until_complete_nesting The test checks that coro1 emits a runtime warning when it is garbage collected. cpython will do this collection immediately, but other implementations such as PyPy might not. Add the appropriate call to support.gc_collect() to ensure the warning is emitted while still in the with statement. --- Lib/test/test_asyncio/test_events.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 919d543b0329e9..53eb5c7a699ff0 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -287,6 +287,7 @@ async def coro2(): ): self.assertRaises( RuntimeError, self.loop.run_until_complete, coro2()) + support.gc_collect() # Note: because of the default Windows timing granularity of # 15.6 msec, we use fairly long sleep times here (~100 msec).