Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 26a3563

Browse files
[3.12] gh-110378: Fix test_async_gen_propagates_generator_exit in test_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 <[email protected]>
1 parent c1e8e90 commit 26a3563

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Lib/test/test_contextlib_async.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,11 @@ async def gen():
4949
async with ctx():
5050
yield 11
5151

52-
ret = []
53-
exc = ValueError(22)
54-
with self.assertRaises(ValueError):
55-
async with ctx():
56-
async for val in gen():
57-
ret.append(val)
58-
raise exc
59-
60-
self.assertEqual(ret, [11])
52+
g = gen()
53+
async for val in g:
54+
self.assertEqual(val, 11)
55+
break
56+
await g.aclose()
6157

6258
def test_exit_is_abstract(self):
6359
class MissingAexit(AbstractAsyncContextManager):

0 commit comments

Comments
 (0)