diff --git a/Lib/test/test_asyncio/test_futures2.py b/Lib/test/test_asyncio/test_futures2.py index 57d24190bc0b..60b58850369f 100644 --- a/Lib/test/test_asyncio/test_futures2.py +++ b/Lib/test/test_asyncio/test_futures2.py @@ -3,6 +3,10 @@ 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 diff --git a/Lib/test/test_asyncio/test_protocols.py b/Lib/test/test_asyncio/test_protocols.py index d8cde6d89aad..0f232631867d 100644 --- a/Lib/test/test_asyncio/test_protocols.py +++ b/Lib/test/test_asyncio/test_protocols.py @@ -4,6 +4,12 @@ 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): diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py index 5c06a1aaa830..112273662b20 100644 --- a/Lib/test/test_asyncio/test_runners.py +++ b/Lib/test/test_asyncio/test_runners.py @@ -5,6 +5,10 @@ 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): diff --git a/Lib/test/test_asyncio/test_sock_lowlevel.py b/Lib/test/test_asyncio/test_sock_lowlevel.py index 448d835b04d5..14001a4a5001 100644 --- a/Lib/test/test_asyncio/test_sock_lowlevel.py +++ b/Lib/test/test_asyncio/test_sock_lowlevel.py @@ -10,6 +10,10 @@ from test.support import socket_helper +def tearDownModule(): + asyncio.set_event_loop_policy(None) + + class MyProto(asyncio.Protocol): connected = None done = None diff --git a/Lib/test/test_asyncio/test_transports.py b/Lib/test/test_asyncio/test_transports.py index df448557a7b7..bbdb218efaa3 100644 --- a/Lib/test/test_asyncio/test_transports.py +++ b/Lib/test/test_asyncio/test_transports.py @@ -7,6 +7,12 @@ 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): diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index c3422850ce1b..2f68459d30cd 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -26,6 +26,10 @@ 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 index 000000000000..119107a8fb96 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-02-10-14-33-47.bpo-46708.avLfCb.rst @@ -0,0 +1,2 @@ +Prevent default asyncio event loop policy modification warning after +``test_asyncio`` execution.