From e5284d97b4b69edcf7357e59ae2c47e9c843a5bd Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 3 Jan 2025 10:51:45 +0000 Subject: [PATCH 1/4] gh-128404: remove requires_working_socket from some of test_asyncgen.py --- Lib/test/test_asyncgen.py | 89 +++++++++------------------------------ 1 file changed, 19 insertions(+), 70 deletions(-) diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py index 5bfd789185c675..4ffdd33a3fc136 100644 --- a/Lib/test/test_asyncgen.py +++ b/Lib/test/test_asyncgen.py @@ -1,15 +1,13 @@ +import asyncio import inspect import types import unittest import contextlib from test.support.import_helper import import_module -from test.support import gc_collect, requires_working_socket -asyncio = import_module("asyncio") +from test.support import gc_collect, requires_working_socket, async_yield as _async_yield -requires_working_socket(module=True) - _no_default = object() @@ -17,12 +15,11 @@ class AwaitException(Exception): pass -@types.coroutine -def awaitable(*, throw=False): +async def awaitable(*, throw=False): if throw: - yield ('throw',) + await _async_yield(('throw',)) else: - yield ('result',) + await _async_yield(('result',)) def run_until_complete(coro): @@ -398,12 +395,6 @@ async def gen(): an.send(None) def test_async_gen_asend_throw_concurrent_with_send(self): - import types - - @types.coroutine - def _async_yield(v): - return (yield v) - class MyExc(Exception): pass @@ -431,11 +422,6 @@ async def agenfn(): gen2.send(None) def test_async_gen_athrow_throw_concurrent_with_send(self): - import types - - @types.coroutine - def _async_yield(v): - return (yield v) class MyExc(Exception): pass @@ -464,12 +450,6 @@ async def agenfn(): gen2.send(None) def test_async_gen_asend_throw_concurrent_with_throw(self): - import types - - @types.coroutine - def _async_yield(v): - return (yield v) - class MyExc(Exception): pass @@ -502,11 +482,6 @@ async def agenfn(): gen2.send(None) def test_async_gen_athrow_throw_concurrent_with_throw(self): - import types - - @types.coroutine - def _async_yield(v): - return (yield v) class MyExc(Exception): pass @@ -572,12 +547,6 @@ async def gen(): aclose.close() def test_async_gen_asend_close_runtime_error(self): - import types - - @types.coroutine - def _async_yield(v): - return (yield v) - async def agenfn(): try: await _async_yield(None) @@ -593,11 +562,6 @@ async def agenfn(): gen.close() def test_async_gen_athrow_close_runtime_error(self): - import types - - @types.coroutine - def _async_yield(v): - return (yield v) class MyExc(Exception): pass @@ -620,6 +584,7 @@ async def agenfn(): gen.close() +@requires_working_socket() class AsyncGenAsyncioTest(unittest.TestCase): def setUp(self): @@ -710,7 +675,6 @@ async def __anext__(self): self.check_async_iterator_anext(MyAsyncIter) def test_python_async_iterator_types_coroutine_anext(self): - import types class MyAsyncIterWithTypesCoro: """Asynchronously yield 1, then 2.""" def __init__(self): @@ -852,10 +816,6 @@ async def do_test(): self.assertEqual(result, "completed") def test_anext_iter(self): - @types.coroutine - def _async_yield(v): - return (yield v) - class MyError(Exception): pass @@ -897,16 +857,15 @@ def test3(anext): self.assertEqual(g.send(None), 1) def test4(anext): - @types.coroutine - def _async_yield(v): - yield v * 10 - return (yield (v * 10 + 1)) + async def yield_twice(v): + await _async_yield(v*10) + return await _async_yield(v*10 + 1) async def agenfn(): try: - await _async_yield(1) + await yield_twice(1) except MyError: - await _async_yield(2) + await yield_twice(2) return yield @@ -918,14 +877,13 @@ async def agenfn(): g.throw(MyError('val')) def test5(anext): - @types.coroutine - def _async_yield(v): - yield v * 10 - return (yield (v * 10 + 1)) + async def yield_twice(v): + await _async_yield(v*10) + return await _async_yield(v*10 + 1) async def agenfn(): try: - await _async_yield(1) + await yield_twice(1) except MyError: return yield 'aaa' @@ -937,13 +895,12 @@ async def agenfn(): g.throw(MyError()) def test6(anext): - @types.coroutine - def _async_yield(v): - yield v * 10 - return (yield (v * 10 + 1)) + async def yield_twice(v): + await _async_yield(v*10) + return await _async_yield(v*10 + 1) async def agenfn(): - await _async_yield(1) + await yield_twice(1) yield 'aaa' agen = agenfn() @@ -2010,10 +1967,6 @@ class MyException(Exception): gc_collect() # does not warn unawaited def test_asend_send_already_running(self): - @types.coroutine - def _async_yield(v): - return (yield v) - async def agenfn(): while True: await _async_yield(1) @@ -2034,10 +1987,6 @@ async def agenfn(): def test_athrow_send_already_running(self): - @types.coroutine - def _async_yield(v): - return (yield v) - async def agenfn(): while True: await _async_yield(1) From de493c47b269999298aeb6f1898b644232886f4d Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 3 Jan 2025 11:10:59 +0000 Subject: [PATCH 2/4] extract some tests that don't need asyncio from under requires_working_socket --- Lib/test/test_asyncgen.py | 648 +++++++++++++++++++------------------- 1 file changed, 328 insertions(+), 320 deletions(-) diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py index 4ffdd33a3fc136..03c7ef2f6858f5 100644 --- a/Lib/test/test_asyncgen.py +++ b/Lib/test/test_asyncgen.py @@ -1,3 +1,4 @@ +import functools import asyncio import inspect import types @@ -583,18 +584,188 @@ async def agenfn(): with self.assertRaisesRegex(RuntimeError, "coroutine ignored GeneratorExit"): gen.close() + def test_aiter_idempotent(self): + async def gen(): + yield 1 + applied_once = aiter(gen()) + applied_twice = aiter(applied_once) + self.assertIs(applied_once, applied_twice) + + def test_anext_iter(self): + class MyError(Exception): + pass + + async def agenfn(): + try: + await _async_yield(1) + except MyError: + await _async_yield(2) + return + yield + + def test1(anext): + agen = agenfn() + with contextlib.closing(anext(agen, "default").__await__()) as g: + self.assertEqual(g.send(None), 1) + self.assertEqual(g.throw(MyError()), 2) + try: + g.send(None) + except StopIteration as e: + err = e + else: + self.fail('StopIteration was not raised') + self.assertEqual(err.value, "default") + + def test2(anext): + agen = agenfn() + with contextlib.closing(anext(agen, "default").__await__()) as g: + self.assertEqual(g.send(None), 1) + self.assertEqual(g.throw(MyError()), 2) + with self.assertRaises(MyError): + g.throw(MyError()) + + def test3(anext): + agen = agenfn() + with contextlib.closing(anext(agen, "default").__await__()) as g: + self.assertEqual(g.send(None), 1) + g.close() + with self.assertRaisesRegex(RuntimeError, 'cannot reuse'): + self.assertEqual(g.send(None), 1) + + def test4(anext): + async def yield_twice(v): + await _async_yield(v*10) + return await _async_yield(v*10 + 1) + + async def agenfn(): + try: + await yield_twice(1) + except MyError: + await yield_twice(2) + return + yield + + agen = agenfn() + with contextlib.closing(anext(agen, "default").__await__()) as g: + self.assertEqual(g.send(None), 10) + self.assertEqual(g.throw(MyError()), 20) + with self.assertRaisesRegex(MyError, 'val'): + g.throw(MyError('val')) + + def test5(anext): + async def yield_twice(v): + await _async_yield(v*10) + return await _async_yield(v*10 + 1) + + async def agenfn(): + try: + await yield_twice(1) + except MyError: + return + yield 'aaa' + + agen = agenfn() + with contextlib.closing(anext(agen, "default").__await__()) as g: + self.assertEqual(g.send(None), 10) + with self.assertRaisesRegex(StopIteration, 'default'): + g.throw(MyError()) + + def test6(anext): + async def yield_twice(v): + await _async_yield(v*10) + return await _async_yield(v*10 + 1) + + async def agenfn(): + await yield_twice(1) + yield 'aaa' + + agen = agenfn() + with contextlib.closing(anext(agen, "default").__await__()) as g: + with self.assertRaises(MyError): + g.throw(MyError()) + + def run_test(test): + with self.subTest('pure-Python anext()'): + test(py_anext) + with self.subTest('builtin anext()'): + test(anext) + + run_test(test1) + run_test(test2) + run_test(test3) + run_test(test4) + run_test(test5) + run_test(test6) + + def test_async_gen_throw_custom_same_aclose_coro_twice(self): + async def async_iterate(): + yield 1 + yield 2 + + it = async_iterate() + + class MyException(Exception): + pass + + nxt = it.aclose() + with self.assertRaises(MyException): + nxt.throw(MyException) + + with self.assertRaisesRegex( + RuntimeError, + r"cannot reuse already awaited aclose\(\)/athrow\(\)" + ): + nxt.throw(MyException) + + def test_async_gen_throw_custom_same_athrow_coro_twice(self): + async def async_iterate(): + yield 1 + yield 2 + + it = async_iterate() + + class MyException(Exception): + pass + + nxt = it.athrow(MyException) + with self.assertRaises(MyException): + nxt.throw(MyException) + + with self.assertRaisesRegex( + RuntimeError, + r"cannot reuse already awaited aclose\(\)/athrow\(\)" + ): + nxt.throw(MyException) + + def test_async_gen_throw_same_aclose_coro_twice(self): + async def async_iterate(): + yield 1 + yield 2 + + it = async_iterate() + nxt = it.aclose() + with self.assertRaises(StopIteration): + nxt.throw(GeneratorExit) + + with self.assertRaisesRegex( + RuntimeError, + r"cannot reuse already awaited aclose\(\)/athrow\(\)" + ): + nxt.throw(GeneratorExit) @requires_working_socket() class AsyncGenAsyncioTest(unittest.TestCase): + loop_used = False - def setUp(self): - self.loop = asyncio.new_event_loop() - asyncio._set_event_loop(None) + @functools.cached_property + def loop(self): + self.loop_used = True + loop = asyncio.EventLoop() + self.addCleanup(loop.close) + return loop def tearDown(self): - self.loop.close() - self.loop = None - asyncio._set_event_loop_policy(None) + self.assertTrue(self.loop_used) def check_async_iterator_anext(self, ait_class): with self.subTest(anext="pure-Python"): @@ -719,13 +890,6 @@ async def consume(): self.loop.run_until_complete(consume()) self.assertEqual(results, [1, 2]) - def test_aiter_idempotent(self): - async def gen(): - yield 1 - applied_once = aiter(gen()) - applied_twice = aiter(applied_once) - self.assertIs(applied_once, applied_twice) - def test_anext_bad_args(self): async def gen(): yield 1 @@ -815,159 +979,53 @@ async def do_test(): result = self.loop.run_until_complete(do_test()) self.assertEqual(result, "completed") - def test_anext_iter(self): - class MyError(Exception): - pass + def test_aiter_bad_args(self): + async def gen(): + yield 1 + async def call_with_too_few_args(): + await aiter() + async def call_with_too_many_args(): + await aiter(gen(), 1) + async def call_with_wrong_type_arg(): + await aiter(1) + with self.assertRaises(TypeError): + self.loop.run_until_complete(call_with_too_few_args()) + with self.assertRaises(TypeError): + self.loop.run_until_complete(call_with_too_many_args()) + with self.assertRaises(TypeError): + self.loop.run_until_complete(call_with_wrong_type_arg()) - async def agenfn(): - try: - await _async_yield(1) - except MyError: - await _async_yield(2) + async def to_list(self, gen): + res = [] + async for i in gen: + res.append(i) + return res + + def test_async_gen_asyncio_01(self): + async def gen(): + yield 1 + await asyncio.sleep(0.01) + yield 2 + await asyncio.sleep(0.01) return - yield + yield 3 - def test1(anext): - agen = agenfn() - with contextlib.closing(anext(agen, "default").__await__()) as g: - self.assertEqual(g.send(None), 1) - self.assertEqual(g.throw(MyError()), 2) - try: - g.send(None) - except StopIteration as e: - err = e - else: - self.fail('StopIteration was not raised') - self.assertEqual(err.value, "default") + res = self.loop.run_until_complete(self.to_list(gen())) + self.assertEqual(res, [1, 2]) - def test2(anext): - agen = agenfn() - with contextlib.closing(anext(agen, "default").__await__()) as g: - self.assertEqual(g.send(None), 1) - self.assertEqual(g.throw(MyError()), 2) - with self.assertRaises(MyError): - g.throw(MyError()) + def test_async_gen_asyncio_02(self): + async def gen(): + yield 1 + await asyncio.sleep(0.01) + yield 2 + 1 / 0 + yield 3 - def test3(anext): - agen = agenfn() - with contextlib.closing(anext(agen, "default").__await__()) as g: - self.assertEqual(g.send(None), 1) - g.close() - with self.assertRaisesRegex(RuntimeError, 'cannot reuse'): - self.assertEqual(g.send(None), 1) + with self.assertRaises(ZeroDivisionError): + self.loop.run_until_complete(self.to_list(gen())) - def test4(anext): - async def yield_twice(v): - await _async_yield(v*10) - return await _async_yield(v*10 + 1) - - async def agenfn(): - try: - await yield_twice(1) - except MyError: - await yield_twice(2) - return - yield - - agen = agenfn() - with contextlib.closing(anext(agen, "default").__await__()) as g: - self.assertEqual(g.send(None), 10) - self.assertEqual(g.throw(MyError()), 20) - with self.assertRaisesRegex(MyError, 'val'): - g.throw(MyError('val')) - - def test5(anext): - async def yield_twice(v): - await _async_yield(v*10) - return await _async_yield(v*10 + 1) - - async def agenfn(): - try: - await yield_twice(1) - except MyError: - return - yield 'aaa' - - agen = agenfn() - with contextlib.closing(anext(agen, "default").__await__()) as g: - self.assertEqual(g.send(None), 10) - with self.assertRaisesRegex(StopIteration, 'default'): - g.throw(MyError()) - - def test6(anext): - async def yield_twice(v): - await _async_yield(v*10) - return await _async_yield(v*10 + 1) - - async def agenfn(): - await yield_twice(1) - yield 'aaa' - - agen = agenfn() - with contextlib.closing(anext(agen, "default").__await__()) as g: - with self.assertRaises(MyError): - g.throw(MyError()) - - def run_test(test): - with self.subTest('pure-Python anext()'): - test(py_anext) - with self.subTest('builtin anext()'): - test(anext) - - run_test(test1) - run_test(test2) - run_test(test3) - run_test(test4) - run_test(test5) - run_test(test6) - - def test_aiter_bad_args(self): - async def gen(): - yield 1 - async def call_with_too_few_args(): - await aiter() - async def call_with_too_many_args(): - await aiter(gen(), 1) - async def call_with_wrong_type_arg(): - await aiter(1) - with self.assertRaises(TypeError): - self.loop.run_until_complete(call_with_too_few_args()) - with self.assertRaises(TypeError): - self.loop.run_until_complete(call_with_too_many_args()) - with self.assertRaises(TypeError): - self.loop.run_until_complete(call_with_wrong_type_arg()) - - async def to_list(self, gen): - res = [] - async for i in gen: - res.append(i) - return res - - def test_async_gen_asyncio_01(self): - async def gen(): - yield 1 - await asyncio.sleep(0.01) - yield 2 - await asyncio.sleep(0.01) - return - yield 3 - - res = self.loop.run_until_complete(self.to_list(gen())) - self.assertEqual(res, [1, 2]) - - def test_async_gen_asyncio_02(self): - async def gen(): - yield 1 - await asyncio.sleep(0.01) - yield 2 - 1 / 0 - yield 3 - - with self.assertRaises(ZeroDivisionError): - self.loop.run_until_complete(self.to_list(gen())) - - def test_async_gen_asyncio_03(self): - loop = self.loop + def test_async_gen_asyncio_03(self): + loop = self.loop class Gen: async def __aiter__(self): @@ -1643,87 +1701,6 @@ async def wait(): self.assertEqual(finalized, 2) - def test_async_gen_asyncio_shutdown_02(self): - messages = [] - - def exception_handler(loop, context): - messages.append(context) - - async def async_iterate(): - yield 1 - yield 2 - - it = async_iterate() - async def main(): - loop = asyncio.get_running_loop() - loop.set_exception_handler(exception_handler) - - async for i in it: - break - - asyncio.run(main()) - - self.assertEqual(messages, []) - - def test_async_gen_asyncio_shutdown_exception_01(self): - messages = [] - - def exception_handler(loop, context): - messages.append(context) - - async def async_iterate(): - try: - yield 1 - yield 2 - finally: - 1/0 - - it = async_iterate() - async def main(): - loop = asyncio.get_running_loop() - loop.set_exception_handler(exception_handler) - - async for i in it: - break - - asyncio.run(main()) - - message, = messages - self.assertEqual(message['asyncgen'], it) - self.assertIsInstance(message['exception'], ZeroDivisionError) - self.assertIn('an error occurred during closing of asynchronous generator', - message['message']) - - def test_async_gen_asyncio_shutdown_exception_02(self): - messages = [] - - def exception_handler(loop, context): - messages.append(context) - - async def async_iterate(): - try: - yield 1 - yield 2 - finally: - 1/0 - - async def main(): - loop = asyncio.get_running_loop() - loop.set_exception_handler(exception_handler) - - async for i in async_iterate(): - break - gc_collect() - - asyncio.run(main()) - - message, = messages - self.assertIsInstance(message['exception'], ZeroDivisionError) - self.assertIn('unhandled exception during asyncio.run() shutdown', - message['message']) - del message, messages - gc_collect() - def test_async_gen_expression_01(self): async def arange(n): for i in range(n): @@ -1755,29 +1732,6 @@ async def run(): res = self.loop.run_until_complete(run()) self.assertEqual(res, [i * 2 for i in range(1, 10)]) - def test_asyncgen_nonstarted_hooks_are_cancellable(self): - # See https://bugs.python.org/issue38013 - messages = [] - - def exception_handler(loop, context): - messages.append(context) - - async def async_iterate(): - yield 1 - yield 2 - - async def main(): - loop = asyncio.get_running_loop() - loop.set_exception_handler(exception_handler) - - async for i in async_iterate(): - break - - asyncio.run(main()) - - self.assertEqual([], messages) - gc_collect() - def test_async_gen_await_same_anext_coro_twice(self): async def async_iterate(): yield 1 @@ -1814,62 +1768,6 @@ async def run(): self.loop.run_until_complete(run()) - def test_async_gen_throw_same_aclose_coro_twice(self): - async def async_iterate(): - yield 1 - yield 2 - - it = async_iterate() - nxt = it.aclose() - with self.assertRaises(StopIteration): - nxt.throw(GeneratorExit) - - with self.assertRaisesRegex( - RuntimeError, - r"cannot reuse already awaited aclose\(\)/athrow\(\)" - ): - nxt.throw(GeneratorExit) - - def test_async_gen_throw_custom_same_aclose_coro_twice(self): - async def async_iterate(): - yield 1 - yield 2 - - it = async_iterate() - - class MyException(Exception): - pass - - nxt = it.aclose() - with self.assertRaises(MyException): - nxt.throw(MyException) - - with self.assertRaisesRegex( - RuntimeError, - r"cannot reuse already awaited aclose\(\)/athrow\(\)" - ): - nxt.throw(MyException) - - def test_async_gen_throw_custom_same_athrow_coro_twice(self): - async def async_iterate(): - yield 1 - yield 2 - - it = async_iterate() - - class MyException(Exception): - pass - - nxt = it.athrow(MyException) - with self.assertRaises(MyException): - nxt.throw(MyException) - - with self.assertRaisesRegex( - RuntimeError, - r"cannot reuse already awaited aclose\(\)/athrow\(\)" - ): - nxt.throw(MyException) - def test_async_gen_aclose_twice_with_different_coros(self): # Regression test for https://bugs.python.org/issue39606 async def async_iterate(): @@ -2005,5 +1903,115 @@ async def agenfn(): del gen2 gc_collect() # does not warn unawaited + +@requires_working_socket() +class AsyncGenAsyncioRunTestCase(unittest.TestCase): + def test_async_gen_asyncio_shutdown_02(self): + messages = [] + + def exception_handler(loop, context): + messages.append(context) + + async def async_iterate(): + yield 1 + yield 2 + + it = async_iterate() + async def main(): + loop = asyncio.get_running_loop() + loop.set_exception_handler(exception_handler) + + async for i in it: + break + + asyncio.run(main()) + + self.assertEqual(messages, []) + + def test_async_gen_asyncio_shutdown_exception_01(self): + messages = [] + + def exception_handler(loop, context): + messages.append(context) + + async def async_iterate(): + try: + yield 1 + yield 2 + finally: + 1/0 + + it = async_iterate() + async def main(): + loop = asyncio.get_running_loop() + loop.set_exception_handler(exception_handler) + + async for i in it: + break + + asyncio.run(main()) + + message, = messages + self.assertEqual(message['asyncgen'], it) + self.assertIsInstance(message['exception'], ZeroDivisionError) + self.assertIn('an error occurred during closing of asynchronous generator', + message['message']) + + def test_async_gen_asyncio_shutdown_exception_02(self): + messages = [] + + def exception_handler(loop, context): + messages.append(context) + + async def async_iterate(): + try: + yield 1 + yield 2 + finally: + 1/0 + + async def main(): + loop = asyncio.get_running_loop() + loop.set_exception_handler(exception_handler) + + async for i in async_iterate(): + break + gc_collect() + + asyncio.run(main()) + + message, = messages + self.assertIsInstance(message['exception'], ZeroDivisionError) + self.assertIn('unhandled exception during asyncio.run() shutdown', + message['message']) + del message, messages + gc_collect() + + def test_asyncgen_nonstarted_hooks_are_cancellable(self): + # See https://bugs.python.org/issue38013 + messages = [] + + def exception_handler(loop, context): + messages.append(context) + + async def async_iterate(): + yield 1 + yield 2 + + async def main(): + loop = asyncio.get_running_loop() + loop.set_exception_handler(exception_handler) + + async for i in async_iterate(): + break + + asyncio.run(main()) + + self.assertEqual([], messages) + gc_collect() + + + + if __name__ == "__main__": unittest.main() From d74471e711ee8409c25a72f8371cef8b9008e42d Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 3 Jan 2025 11:11:50 +0000 Subject: [PATCH 3/4] Update Lib/test/test_asyncgen.py --- Lib/test/test_asyncgen.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py index 03c7ef2f6858f5..e8aff256609243 100644 --- a/Lib/test/test_asyncgen.py +++ b/Lib/test/test_asyncgen.py @@ -2011,7 +2011,5 @@ async def main(): gc_collect() - - if __name__ == "__main__": unittest.main() From a80de9cc01578eb9072fc5165bb05132231f58a4 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sat, 4 Jan 2025 07:32:27 +0000 Subject: [PATCH 4/4] avoid setting the policy in test_asyngen --- Lib/test/test_asyncgen.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py index e8aff256609243..4cb1bef8d0f15b 100644 --- a/Lib/test/test_asyncgen.py +++ b/Lib/test/test_asyncgen.py @@ -1904,6 +1904,9 @@ async def agenfn(): gc_collect() # does not warn unawaited +_asyncio_run = functools.partial(asyncio.run, loop_factory=asyncio.EventLoop) + + @requires_working_socket() class AsyncGenAsyncioRunTestCase(unittest.TestCase): def test_async_gen_asyncio_shutdown_02(self): @@ -1924,7 +1927,7 @@ async def main(): async for i in it: break - asyncio.run(main()) + _asyncio_run(main()) self.assertEqual(messages, []) @@ -1949,7 +1952,7 @@ async def main(): async for i in it: break - asyncio.run(main()) + _asyncio_run(main()) message, = messages self.assertEqual(message['asyncgen'], it) @@ -1978,7 +1981,7 @@ async def main(): break gc_collect() - asyncio.run(main()) + _asyncio_run(main()) message, = messages self.assertIsInstance(message['exception'], ZeroDivisionError) @@ -2005,7 +2008,7 @@ async def main(): async for i in async_iterate(): break - asyncio.run(main()) + _asyncio_run(main()) self.assertEqual([], messages) gc_collect()