8000 fix various warnings in `test_asyncio.test_tasks` (#131109) · python/cpython@fcf756a · GitHub
[go: up one dir, main page]

Skip to content

Commit fcf756a

Browse files
fix various warnings in test_asyncio.test_tasks (#131109)
1 parent 8b1edae commit fcf756a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Lib/test/test_asyncio/test_tasks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,16 +2301,19 @@ class Subclass(Task):
23012301
def __del__(self):
23022302
pass
23032303

2304-
async def coro():
2304+
async def corofn():
23052305
await asyncio.sleep(0.01)
23062306

2307-
task = Subclass(coro(), loop = self.loop)
2307+
coro = corofn()
2308+
task = Subclass(coro, loop = self.loop)
23082309
task._log_destroy_pending = False
23092310

23102311
del task
23112312

23122313
support.gc_collect()
23132314

2315+
coro.close()
2316+
23142317
@mock.patch('asyncio.base_events.logger')
23152318
def test_tb_logger_not_called_after_cancel(self, m_log):
23162319
loop = asyncio.new_event_loop()
@@ -2716,12 +2719,12 @@ def __str__(self):
27162719
coro = coroutine_function()
27172720
with contextlib.closing(asyncio.EventLoop()) as loop:
27182721
task = asyncio.Task.__new__(asyncio.Task)
2719-
27202722
for _ in range(5):
27212723
with self.assertRaisesRegex(RuntimeError, 'break'):
27222724
task.__init__(coro, loop=loop, context=obj, name=Break())
27232725

27242726
coro.close()
2727+
task._log_destroy_pending = False
27252728
del task
27262729

27272730
self.assertEqual(sys.getrefcount(obj), initial_refcount)

0 commit comments

Comments
 (0)
0