gh-112186: Improve test case test_loop_is_closed_resource_warnings (#112187)

This commit is contained in:
DPR 2023-11-19 11:21:34 +08:00 committed by GitHub
parent 2bcc0f7d34
commit 18c6929469
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1122,13 +1122,10 @@ async def inner(httpd):
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, [])