diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py index 540964a9bfd..ca7315783b9 100644 --- a/Lib/test/test_contextlib_async.py +++ b/Lib/test/test_contextlib_async.py @@ -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):