]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix warning: asyncio.events._event_loop_policy was modified by test_asyncio (GH-31253)
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Thu, 10 Feb 2022 12:57:20 +0000 (14:57 +0200)
committerGitHub <noreply@github.com>
Thu, 10 Feb 2022 12:57:20 +0000 (14:57 +0200)
Lib/test/test_asyncio/test_futures2.py
Lib/test/test_asyncio/test_protocols.py
Lib/test/test_asyncio/test_runners.py
Lib/test/test_asyncio/test_sock_lowlevel.py
Lib/test/test_asyncio/test_transports.py
Lib/test/test_asyncio/test_unix_events.py
Misc/NEWS.d/next/Tests/2022-02-10-14-33-47.bpo-46708.avLfCb.rst [new file with mode: 0644]

index 57d24190bc0bd5f198a799197a00943436bdf027..60b58850369f053fd832f49bae461af4c10b4020 100644 (file)
@@ -3,6 +3,10 @@ import asyncio
 import unittest
 
 
+def tearDownModule():
+    asyncio.set_event_loop_policy(None)
+
+
 class FutureTests(unittest.IsolatedAsyncioTestCase):
     async def test_recursive_repr_for_pending_tasks(self):
         # The call crashes if the guard for recursive call
index d8cde6d89aadcde0ec31e6172ed2df7e057e4e56..0f232631867db56c17f0bd77eeccd502e4586146 100644 (file)
@@ -4,6 +4,12 @@ from unittest import mock
 import asyncio
 
 
+def tearDownModule():
+    # not needed for the test file but added for uniformness with all other
+    # asyncio test files for the sake of unified cleanup
+    asyncio.set_event_loop_policy(None)
+
+
 class ProtocolsAbsTests(unittest.TestCase):
 
     def test_base_protocol(self):
index 5c06a1aaa830fab4c12f00c63cc2176b089544a8..112273662b20b55bebf54e81a27575c54ce2f86b 100644 (file)
@@ -5,6 +5,10 @@ from unittest import mock
 from test.test_asyncio import utils as test_utils
 
 
+def tearDownModule():
+    asyncio.set_event_loop_policy(None)
+
+
 class TestPolicy(asyncio.AbstractEventLoopPolicy):
 
     def __init__(self, loop_factory):
index 448d835b04d5709734e1fa31203c6dd6d2a626f9..14001a4a5001f8cc202a523db0adb2e2854ac31c 100644 (file)
@@ -10,6 +10,10 @@ from test import support
 from test.support import socket_helper
 
 
+def tearDownModule():
+    asyncio.set_event_loop_policy(None)
+
+
 class MyProto(asyncio.Protocol):
     connected = None
     done = None
index df448557a7b7fcde07f7017e4015bdecb80be8ab..bbdb218efaa3b6594d4e1921d513dfa39b92166b 100644 (file)
@@ -7,6 +7,12 @@ import asyncio
 from asyncio import transports
 
 
+def tearDownModule():
+    # not needed for the test file but added for uniformness with all other
+    # asyncio test files for the sake of unified cleanup
+    asyncio.set_event_loop_policy(None)
+
+
 class TransportTests(unittest.TestCase):
 
     def test_ctor_extra_is_none(self):
index c3422850ce1b70d72e0c784f064ffdf27868751a..2f68459d30cd482ef86399c7148b2b959cb7d886 100644 (file)
@@ -26,6 +26,10 @@ from asyncio import unix_events
 from test.test_asyncio import utils as test_utils
 
 
+def tearDownModule():
+    asyncio.set_event_loop_policy(None)
+
+
 MOCK_ANY = mock.ANY
 
 
@@ -39,10 +43,6 @@ def SIGNAL(signum):
     return 32768 - signum
 
 
-def tearDownModule():
-    asyncio.set_event_loop_policy(None)
-
-
 def close_pipe_transport(transport):
     # Don't call transport.close() because the event loop and the selector
     # are mocked
diff --git a/Misc/NEWS.d/next/Tests/2022-02-10-14-33-47.bpo-46708.avLfCb.rst b/Misc/NEWS.d/next/Tests/2022-02-10-14-33-47.bpo-46708.avLfCb.rst
new file mode 100644 (file)
index 0000000..119107a
--- /dev/null
@@ -0,0 +1,2 @@
+Prevent default asyncio event loop policy modification warning after
+``test_asyncio`` execution.