8000 add test_wait_for_cancellation_propagates · python/cpython@54f4895 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54f4895

Browse files
committed
add test_wait_for_cancellation_propagates
1 parent c6af08b commit 54f4895

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_asyncio/test_waitfor.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,19 @@ async def test_cancel_blocking_wait_for(self):
289289
async def test_cancel_wait_for(self):
290290
await self._test_cancel_wait_for(60.0)
291291

292+
async def test_wait_for_cancellation_propagates(self):
293+
# https://github.com/python/cpython/issues/86296
294+
inner = asyncio.get_running_loop().create_future()
295+
outer = asyncio.wait_for(inner, 0.1)
296+
outer_future = asyncio.create_task(outer)
297+
await asyncio.sleep(0)
298+
inner.set_result(None) # inner is done
299+
outer_future.cancel() # AND outer got cancelled
300+
301+
# this fails starting with Python 3.8
302+
with self.assertRaises(asyncio.CancelledError):
303+
await outer_future
304+
292305

293306
if __name__ == '__main__':
294307
unittest.main()

0 commit comments

Comments
 (0)
0