8000 gh-110378: Fix test_async_gen_propagates_generator_exit in test_conte… · serhiy-storchaka/cpython@f11f46e · GitHub
[go: up one dir, main page]

Skip to content

Commit f11f46e

Browse files
pythongh-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.
1 parent 92ca90b commit f11f46e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Lib/test/test_contextlib_async.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,11 @@ async def gen():
6161
async with ctx():
6262
yield 11
6363

64-
ret = []
65-
exc = ValueError(22)
66-
with self.assertRaises(ValueError):
67-
async with ctx():
68-
async for val in gen():
69-
ret.append(val)
70-
raise exc
71-
72-
self.assertEqual(ret, [11])
64+
g = gen()
65+
async for val in g:
66+
self.assertEqual(val, 11)
67+
break
68+
await g.aclose()
7369

7470
def test_exit_is_abstract(self):
7571
class MissingAexit(AbstractAsyncContextManager):

0 commit comments

Comments
 (0)
0