MCPcopy Index your code
hub / github.com/python/cpython / test_ensure_future_task

Method test_ensure_future_task

Lib/test/test_asyncio/test_tasks.py:244–263  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

242 self.assertIs(f, f_orig)
243
244 def test_ensure_future_task(self):
245 async def notmuch():
246 return 'ok'
247 t_orig = self.new_task(self.loop, notmuch())
248 t = asyncio.ensure_future(t_orig)
249 self.loop.run_until_complete(t)
250 self.assertTrue(t.done())
251 self.assertEqual(t.result(), 'ok')
252 self.assertIs(t, t_orig)
253
254 loop = asyncio.new_event_loop()
255 self.set_event_loop(loop)
256
257 with self.assertRaises(ValueError):
258 t = asyncio.ensure_future(t_orig, loop=loop)
259
260 loop.close()
261
262 t = asyncio.ensure_future(t_orig, loop=self.loop)
263 self.assertIs(t, t_orig)
264
265 def test_ensure_future_awaitable(self):
266 class Aw:

Callers

nothing calls this directly

Calls 11

new_taskMethod · 0.95
assertTrueMethod · 0.80
run_until_completeMethod · 0.45
doneMethod · 0.45
assertEqualMethod · 0.45
resultMethod · 0.45
assertIsMethod · 0.45
new_event_loopMethod · 0.45
set_event_loopMethod · 0.45
assertRaisesMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected