(self)
| 2163 | self.assertEqual(res, 42) |
| 2164 | |
| 2165 | def test_shield_effect(self): |
| 2166 | # Cancelling outer() does not affect inner(). |
| 2167 | proof = 0 |
| 2168 | waiter = self.new_future(self.loop) |
| 2169 | |
| 2170 | async def inner(): |
| 2171 | nonlocal proof |
| 2172 | await waiter |
| 2173 | proof += 1 |
| 2174 | |
| 2175 | async def outer(): |
| 2176 | nonlocal proof |
| 2177 | await asyncio.shield(inner()) |
| 2178 | proof += 100 |
| 2179 | |
| 2180 | f = asyncio.ensure_future(outer(), loop=self.loop) |
| 2181 | test_utils.run_briefly(self.loop) |
| 2182 | f.cancel() |
| 2183 | with self.assertRaises(asyncio.CancelledError): |
| 2184 | self.loop.run_until_complete(f) |
| 2185 | waiter.set_result(None) |
| 2186 | test_utils.run_briefly(self.loop) |
| 2187 | self.assertEqual(proof, 1) |
| 2188 | |
| 2189 | def test_shield_gather(self): |
| 2190 | child1 = self.new_future(self.loop) |
nothing calls this directly
no test coverage detected