MCPcopy Create free account
hub / github.com/python/cpython / test_yield_from_twice

Method test_yield_from_twice

Lib/test/test_asyncio/test_futures.py:326–342  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

324 self.assertIsInstance(f.exception(), RuntimeError)
325
326 def test_yield_from_twice(self):
327 f = self._new_future(loop=self.loop)
328
329 def fixture():
330 yield 'A'
331 x = yield from f
332 yield 'B', x
333 y = yield from f
334 yield 'C', y
335
336 g = fixture()
337 self.assertEqual(next(g), 'A') # yield 'A'.
338 self.assertEqual(next(g), f) # First yield from f.
339 f.set_result(42)
340 self.assertEqual(next(g), ('B', 42)) # yield 'B', x.
341 # The second "yield from f" does not yield f.
342 self.assertEqual(next(g), ('C', 42)) # yield 'C', y.
343
344 def test_future_repr(self):
345 self.loop.set_debug(True)

Callers

nothing calls this directly

Calls 3

_new_futureMethod · 0.95
assertEqualMethod · 0.45
set_resultMethod · 0.45

Tested by

no test coverage detected