]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-94808: [coverage] Add an asynchronous generator test where the generator is alread...
authorzhanpon <pon.zhan@gmail.com>
Thu, 24 Nov 2022 09:10:38 +0000 (18:10 +0900)
committerGitHub <noreply@github.com>
Thu, 24 Nov 2022 09:10:38 +0000 (14:40 +0530)
Lib/test/test_asyncgen.py

index f6184c0cab469464101d309fa60e4dbc04aa81aa..0421efdbf9dac9ae30ad556ba662e4e39964387a 100644 (file)
@@ -378,6 +378,19 @@ class AsyncGenTest(unittest.TestCase):
 
         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