]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109862: Fix test_create_subprocess_with_pidfd when it was run separately (GH-113991)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 15 Jan 2024 07:26:49 +0000 (09:26 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Jan 2024 07:26:49 +0000 (09:26 +0200)
Lib/test/test_asyncio/test_subprocess.py

index 179c8cb8cc17cf89805443699cf0a349efe7a367..859d2932c33fedec4a64f13166d36f3ef39ebe74 100644 (file)
@@ -975,8 +975,13 @@ if sys.platform != 'win32':
 
             async def main():
                 # asyncio.Runner did not call asyncio.set_event_loop()
-                with self.assertRaises(RuntimeError):
-                    asyncio.get_event_loop_policy().get_event_loop()
+                with warnings.catch_warnings():
+                    warnings.simplefilter('error', DeprecationWarning)
+                    # get_event_loop() raises DeprecationWarning if
+                    # set_event_loop() was never called and RuntimeError if
+                    # it was called at least once.
+                    with self.assertRaises((RuntimeError, DeprecationWarning)):
+                        asyncio.get_event_loop_policy().get_event_loop()
                 return await asyncio.to_thread(asyncio.run, in_thread())
             with self.assertWarns(DeprecationWarning):
                 asyncio.set_child_watcher(asyncio.PidfdChildWatcher())