aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
authorKumar Aditya <kumaraditya@python.org>2025-03-12 01:21:53 +0530
committerGitHub <noreply@github.com>2025-03-11 19:51:53 +0000
commitfcf756adef43a15e5bc2b397d95ca8c6a54d524d (patch)
tree2b13839aa770fa5adfa2be3d017cbd01052f43ff /Lib/test/test_asyncio/test_tasks.py
parent8b1edae93a05cc90c5b8c5c935f3753aca938ccf (diff)
downloadcpython-fcf756adef43a15e5bc2b397d95ca8c6a54d524d.tar.gz
cpython-fcf756adef43a15e5bc2b397d95ca8c6a54d524d.zip
fix various warnings in `test_asyncio.test_tasks` (#131109)
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 591b48b88a2..f1a665e5df3 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2301,16 +2301,19 @@ class BaseTaskTests:
def __del__(self):
pass
- async def coro():
+ async def corofn():
await asyncio.sleep(0.01)
- task = Subclass(coro(), loop = self.loop)
+ coro = corofn()
+ task = Subclass(coro, loop = self.loop)
task._log_destroy_pending = False
del task
support.gc_collect()
+ coro.close()
+
@mock.patch('asyncio.base_events.logger')
def test_tb_logger_not_called_after_cancel(self, m_log):
loop = asyncio.new_event_loop()
@@ -2716,12 +2719,12 @@ class BaseTaskTests:
coro = coroutine_function()
with contextlib.closing(asyncio.EventLoop()) as loop:
task = asyncio.Task.__new__(asyncio.Task)
-
for _ in range(5):
with self.assertRaisesRegex(RuntimeError, 'break'):
task.__init__(coro, loop=loop, context=obj, name=Break())
coro.close()
+ task._log_destroy_pending = False
del task
self.assertEqual(sys.getrefcount(obj), initial_refcount)