]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-112186: Improve test case `test_loop_is_closed_resource_warnings` (GH-11218...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 19 Nov 2023 15:19:12 +0000 (16:19 +0100)
committerGitHub <noreply@github.com>
Sun, 19 Nov 2023 15:19:12 +0000 (07:19 -0800)
(cherry picked from commit 18c692946953e586db432fd06c856531a2b05127)

Co-authored-by: DPR <dpr-0xff@pm.me>
Lib/test/test_asyncio/test_streams.py

index ccb7dbf667c3202f56983edcfc594d950b2b3560..b408cd1f7da205a4e8c1d095ab5155a2600bb5a0 100644 (file)
@@ -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, [])