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

Method test_ensure_future_future

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

Source from the content-addressed store, hash-verified

221 self.assertEqual(t.result(), 'ok')
222
223 def test_ensure_future_future(self):
224 f_orig = self.new_future(self.loop)
225 f_orig.set_result('ko')
226
227 f = asyncio.ensure_future(f_orig)
228 self.loop.run_until_complete(f)
229 self.assertTrue(f.done())
230 self.assertEqual(f.result(), 'ko')
231 self.assertIs(f, f_orig)
232
233 loop = asyncio.new_event_loop()
234 self.set_event_loop(loop)
235
236 with self.assertRaises(ValueError):
237 f = asyncio.ensure_future(f_orig, loop=loop)
238
239 loop.close()
240
241 f = asyncio.ensure_future(f_orig, loop=self.loop)
242 self.assertIs(f, f_orig)
243
244 def test_ensure_future_task(self):
245 async def notmuch():

Callers

nothing calls this directly

Calls 12

new_futureMethod · 0.95
assertTrueMethod · 0.80
set_resultMethod · 0.45
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