summaryrefslogtreecommitdiff
path: root/Lib/test/test_contextlib_async.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_contextlib_async.py')
-rw-r--r--Lib/test/test_contextlib_async.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py
index 355955f9ab..39dcd9b364 100644
--- a/Lib/test/test_contextlib_async.py
+++ b/Lib/test/test_contextlib_async.py
@@ -36,6 +36,28 @@ class TestAbstractAsyncContextManager(unittest.TestCase):
async with manager as context:
self.assertIs(manager, context)
+ @_async_test
+ async def test_async_gen_propagates_generator_exit(self):
+ # A regression test for https://bugs.python.org/issue33786.
+
+ @asynccontextmanager
+ async def ctx():
+ yield
+
+ async def gen():
+ async with ctx():
+ yield 11
+
+ ret = []
+ exc = ValueError(22)
+ with self.assertRaises(ValueError):
+ async with ctx():
+ async for val in gen():
+ ret.append(val)
+ raise exc
+
+ self.assertEqual(ret, [11])
+
def test_exit_is_abstract(self):
class MissingAexit(AbstractAsyncContextManager):
pass