@@ -2254,7 +2254,6 @@ def test_wait_invalid_args(self):
2254
2254
asyncio .wait ([]))
2255
2255
2256
2256
def test_log_destroyed_pending_task (self ):
2257
- Task = self .__class__ .Task
2258
2257
2259
2258
async def kill_me (loop ):
2260
2259
future = self .new_future (loop )
@@ -2269,7 +2268,7 @@ async def kill_me(loop):
2269
2268
2270
2269
# schedule the task
2271
2270
coro = kill_me (self .loop )
2272
- task = asyncio . ensure_future ( coro , loop = self .loop )
2271
+ task = self . new_task ( self .loop , coro )
2273
2272
2274
2273
self .assertEqual (self .all_tasks (loop = self .loop ), {task })
2275
2274
@@ -2286,14 +2285,17 @@ async def kill_me(loop):
2286
2285
# no more reference to kill_me() task: the task is destroyed by the GC
2287
2286
support .gc_collect ()
2288
2287
2289
- self .assertEqual (self .all_tasks (loop = self .loop ), set ())
2290
-
2291
2288
mock_handler .assert_called_with (self .loop , {
2292
2289
'message' : 'Task was destroyed but it is pending!' ,
2293
2290
'task' : mock .ANY ,
2294
2291
'source_traceback' : source_traceback ,
2295
2292
})
2296
2293
mock_handler .reset_mock ()
2294
+ # task got resurrected by the exception handler
2295
+ support .gc_collect ()
2296
+
2297
+ self .assertEqual (self .all_tasks (loop = self .loop ), set ())
2298
+
2297
2299
2298
2300
@mock .patch ('asyncio.base_events.logger' )
2299
2301
def test_tb_logger_not_called_after_cancel (self , m_log ):
0 commit comments