Fix warning: asyncio.events._event_loop_policy was modified by test_asyncio (GH-31253)

This commit is contained in:
Andrew Svetlov 2022-02-10 14:57:20 +02:00 committed by GitHub
parent 4f21d528f0
commit 012e77eb5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 4 deletions

View 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

View 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):

View 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):

View 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

View 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):

View 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

View File

@ -0,0 +1,2 @@
Prevent default asyncio event loop policy modification warning after
``test_asyncio`` execution.