]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-110378: Fix test_async_gen_propagates_generator_exit in test_contextlib_async...
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 10 Oct 2023 09:38:40 +0000 (12:38 +0300)
committerGitHub <noreply@github.com>
Tue, 10 Oct 2023 09:38:40 +0000 (11:38 +0200)
It now fails if the original bug is not fixed, and no longer produce ResourceWarning with fixed code.

Lib/test/test_contextlib_async.py

index 540964a9bfdcfde167165f0a2c146e1344adf569..ca7315783b96745ffd99d10c9bac5e7f17826457 100644 (file)
@@ -49,15 +49,11 @@ class TestAbstractAsyncContextManager(unittest.IsolatedAsyncioTestCase):
             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])
+        g = gen()
+        async for val in g:
+            self.assertEqual(val, 11)
+            break
+        await g.aclose()
 
     def test_exit_is_abstract(self):
         class MissingAexit(AbstractAsyncContextManager):