Skip to content

Commit

Permalink
[3.12] gh-110378: Fix test_async_gen_propagates_generator_exit in tes…
Browse files Browse the repository at this point in the history
…t_contextlib_async (GH-110500) (#110610)

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

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
miss-islington and serhiy-storchaka committed Oct 10, 2023
1 parent c1e8e90 commit 26a3563
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Lib/test/test_contextlib_async.py
Expand Up @@ -49,15 +49,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):
Expand Down

0 comments on commit 26a3563

Please sign in to comment.