summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2022-02-10 13:27:15 (GMT)
committerGitHub <noreply@github.com>2022-02-10 13:27:15 (GMT)
commit9f5145403b40b19e5c00ba43eaa35d5ea2b7b545 (patch)
treebd3aef7536cb4d9c904a36e8f77f3ad706bc337d
parent9b23f8f78fdb0d7eba016616ae7a97abbfc65aa6 (diff)
downloadcpython-9f5145403b40b19e5c00ba43eaa35d5ea2b7b545.zip
cpython-9f5145403b40b19e5c00ba43eaa35d5ea2b7b545.tar.gz
cpython-9f5145403b40b19e5c00ba43eaa35d5ea2b7b545.tar.bz2
[3.10] Fix warning: asyncio.events._event_loop_policy was modified by test_asyncio (GH-31253) (GH-31255)
(cherry picked from commit 012e77eb5c3ba3d411f5967a7f368ebdb42ab88c) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
-rw-r--r--Lib/test/test_asyncio/test_futures2.py4
-rw-r--r--Lib/test/test_asyncio/test_protocols.py6
-rw-r--r--Lib/test/test_asyncio/test_runners.py4
-rw-r--r--Lib/test/test_asyncio/test_sock_lowlevel.py4
-rw-r--r--Lib/test/test_asyncio/test_transports.py6
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py8
-rw-r--r--Misc/NEWS.d/next/Tests/2022-02-10-14-33-47.bpo-46708.avLfCb.rst2
7 files changed, 30 insertions, 4 deletions
diff --git a/Lib/test/test_asyncio/test_futures2.py b/Lib/test/test_asyncio/test_futures2.py
index 57d2419..60b5885 100644
--- a/Lib/test/test_asyncio/test_futures2.py
+++ b/Lib/test/test_asyncio/test_futures2.py
@@ -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
diff --git a/Lib/test/test_asyncio/test_protocols.py b/Lib/test/test_asyncio/test_protocols.py
index d8cde6d..0f23263 100644
--- a/Lib/test/test_asyncio/test_protocols.py
+++ b/Lib/test/test_asyncio/test_protocols.py
@@ -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):
diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py
index 5c06a1a..1122736 100644
--- a/Lib/test/test_asyncio/test_runners.py
+++ b/Lib/test/test_asyncio/test_runners.py
@@ -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):
diff --git a/Lib/test/test_asyncio/test_sock_lowlevel.py b/Lib/test/test_asyncio/test_sock_lowlevel.py
index 448d835..14001a4 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 import support
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 df44855..bbdb218 100644
--- a/Lib/test/test_asyncio/test_transports.py
+++ b/Lib/test/test_asyncio/test_transports.py
@@ -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):
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index c342285..2f68459 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -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
index 0000000..119107a
--- /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.