[Python-checkins] gh-94808: [coverage] Add an asynchronous generator test where the generator is already running (#97672)

kumaraditya303 webhook-mailer at python.org
Thu Nov 24 04:10:48 EST 2022


https://github.com/python/cpython/commit/5f4ae86a639fb84260d622e31468da21dc468265
commit: 5f4ae86a639fb84260d622e31468da21dc468265
branch: main
author: zhanpon <pon.zhan at gmail.com>
committer: kumaraditya303 <59607654+kumaraditya303 at users.noreply.github.com>
date: 2022-11-24T14:40:38+05:30
summary:

gh-94808: [coverage] Add an asynchronous generator test where the generator is already running (#97672)

files:
M Lib/test/test_asyncgen.py

diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py
index f6184c0cab46..0421efdbf9da 100644
--- a/Lib/test/test_asyncgen.py
+++ b/Lib/test/test_asyncgen.py
@@ -378,6 +378,19 @@ async def async_gen_wrapper():
 
         self.compare_generators(sync_gen_wrapper(), async_gen_wrapper())
 
+    def test_async_gen_exception_12(self):
+        async def gen():
+            await anext(me)
+            yield 123
+
+        me = gen()
+        ai = me.__aiter__()
+        an = ai.__anext__()
+
+        with self.assertRaisesRegex(RuntimeError,
+                r'anext\(\): asynchronous generator is already running'):
+            an.__next__()
+
     def test_async_gen_3_arg_deprecation_warning(self):
         async def gen():
             yield 123



More information about the Python-checkins mailing list