]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-110378: Fix test_async_gen_propagates_generator_exit in test_contextlib_asy...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 10 Oct 2023 11:12:40 +0000 (13:12 +0200)
committerGitHub <noreply@github.com>
Tue, 10 Oct 2023 11:12:40 +0000 (13:12 +0200)
It now fails if the original bug is not fixed, and no longer produce ResourceWarning with fixed code.
(cherry picked from commit 5aa62a8de15212577a13966710b3aede46e93824)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_contextlib_async.py

index 3d43ed0fcab1686764695443185509a3686d3738..438bb2dcfcc5eb79bce26bc40cd4038b488731e9 100644 (file)
@@ -49,15 +49,11 @@ class TestAbstractAsyncContextManager(unittest.TestCase):
             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):