[3.11] gh-110378: Fix test_async_gen_propagates_generator_exit in test_contextlib_async (GH-110500) (#110611)

It now fails if the original bug is not fixed, and no longer produce ResourceWarning with fixed code.
(cherry picked from commit 5aa62a8de1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-10-10 13:12:40 +02:00 committed by GitHub
parent 7fefed091a
commit bf1753bb4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,15 +49,11 @@ class TestAbstractAsyncContextManager(unittest.TestCase):
async with ctx(): async with ctx():
yield 11 yield 11
ret = [] g = gen()
exc = ValueError(22) async for val in g:
with self.assertRaises(ValueError): self.assertEqual(val, 11)
async with ctx(): break
async for val in gen(): await g.aclose()
ret.append(val)
raise exc
self.assertEqual(ret, [11])
def test_exit_is_abstract(self): def test_exit_is_abstract(self):
class MissingAexit(AbstractAsyncContextManager): class MissingAexit(AbstractAsyncContextManager):