From f11f46ee4de527df736e85938a7a9c342eca6f23 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 7 Oct 2023 13:21:40 +0300 Subject: [PATCH] gh-110378: Fix test_async_gen_propagates_generator_exit in test_contextlib_async It now fails if the original bug is not fixed, and no longer produce ResourceWarning with fixed code. --- Lib/test/test_contextlib_async.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py index fa89c23f8edd91..e8b965b38392ff 100644 --- a/Lib/test/test_contextlib_async.py +++ b/Lib/test/test_contextlib_async.py @@ -61,15 +61,11 @@ async def gen(): 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):