Skip to content

fix various warnings in test_asyncio.test_tasks #131109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2301,16 +2301,19 @@ class Subclass(Task):
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()
Expand Down Expand Up @@ -2716,12 +2719,12 @@ def __str__(self):
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)
Expand Down
Loading