From: DPR Date: Sun, 19 Nov 2023 03:21:34 +0000 (+0800) Subject: gh-112186: Improve test case `test_loop_is_closed_resource_warnings` (#112187) X-Git-Tag: v3.13.0a2~29 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=18c692946953e586db432fd06c856531a2b05127;p=thirdparty%2FPython%2Fcpython.git gh-112186: Improve test case `test_loop_is_closed_resource_warnings` (#112187) --- diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py index ccb7dbf667c3..b408cd1f7da2 100644 --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -1122,13 +1122,10 @@ os.close(fd) self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx)) with test_utils.run_test_server() as httpd: - try: + with self.assertRaises(RuntimeError): + # This exception is caused by `self.loop.stop()` as expected. self.loop.run_until_complete(inner(httpd)) - # This exception is caused by `self.loop.stop()` as expected. - except RuntimeError: - pass - finally: - gc.collect() + gc.collect() self.assertEqual(messages, [])