diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-01-12 15:30:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-12 15:30:26 (GMT) |
commit | e02c15b3f13d9d83032ada72c6773f8a3b2d34dc (patch) | |
tree | d5271e6ec4f486e6814dd9c551563b1829e7c912 | |
parent | ed066481c76c6888ff5709f5b9f93b92c232a4a6 (diff) | |
download | cpython-e02c15b3f13d9d83032ada72c6773f8a3b2d34dc.zip cpython-e02c15b3f13d9d83032ada72c6773f8a3b2d34dc.tar.gz cpython-e02c15b3f13d9d83032ada72c6773f8a3b2d34dc.tar.bz2 |
gh-113980: Fix resource warnings in test_asyncgen (GH-113984)
-rw-r--r-- | Lib/test/test_asyncgen.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py index 7fa0a85..39605dc 100644 --- a/Lib/test/test_asyncgen.py +++ b/Lib/test/test_asyncgen.py @@ -379,7 +379,10 @@ class AsyncGenTest(unittest.TestCase): def test_async_gen_exception_12(self): async def gen(): - await anext(me) + with self.assertWarnsRegex(RuntimeWarning, + f"coroutine method 'asend' of '{gen.__qualname__}' " + f"was never awaited"): + await anext(me) yield 123 me = gen() @@ -395,7 +398,12 @@ class AsyncGenTest(unittest.TestCase): yield 123 with self.assertWarns(DeprecationWarning): - gen().athrow(GeneratorExit, GeneratorExit(), None) + x = gen().athrow(GeneratorExit, GeneratorExit(), None) + with self.assertWarnsRegex(RuntimeWarning, + f"coroutine method 'athrow' of '{gen.__qualname__}' " + f"was never awaited"): + del x + gc_collect() def test_async_gen_api_01(self): async def gen(): @@ -1564,6 +1572,11 @@ class AsyncGenAsyncioTest(unittest.TestCase): self.assertIsInstance(message['exception'], ZeroDivisionError) self.assertIn('unhandled exception during asyncio.run() shutdown', message['message']) + with self.assertWarnsRegex(RuntimeWarning, + f"coroutine method 'aclose' of '{async_iterate.__qualname__}' " + f"was never awaited"): + del message, messages + gc_collect() def test_async_gen_expression_01(self): async def arange(n): @@ -1617,6 +1630,10 @@ class AsyncGenAsyncioTest(unittest.TestCase): asyncio.run(main()) self.assertEqual([], messages) + with self.assertWarnsRegex(RuntimeWarning, + f"coroutine method 'aclose' of '{async_iterate.__qualname__}' " + f"was never awaited"): + gc_collect() def test_async_gen_await_same_anext_coro_twice(self): async def async_iterate(): |