]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] Fix warning: asyncio.events._event_loop_policy was modified by test_asyncio...
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Thu, 10 Feb 2022 13:32:05 +0000 (15:32 +0200)
committerGitHub <noreply@github.com>
Thu, 10 Feb 2022 13:32:05 +0000 (15:32 +0200)
(cherry picked from commit 012e77eb5c3ba3d411f5967a7f368ebdb42ab88c)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
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 7de27b11154a4ea52857ac647ed17e4a9ddb1722..025c6c0132a971855f5fd198d9c43257350a463e 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 10bd46dea1991d9b8310a691c39a39945ba4eaf6..70d306ffe8fbb90b2469df9556240eac7e09b900 100644 (file)
@@ -27,13 +27,13 @@ from asyncio import unix_events
 from test.test_asyncio import utils as test_utils
 
 
-MOCK_ANY = mock.ANY
-
-
 def tearDownModule():
     asyncio.set_event_loop_policy(None)
 
 
+MOCK_ANY = mock.ANY
+
+
 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.