It now fails if the original bug is not fixed, and no longer produce ResourceWarning with fixed code.
(cherry picked from commit
5aa62a8de15212577a13966710b3aede46e93824)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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):