Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/test/libregrtest/save_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import urllib.request
import warnings
from test import support
from test.support.asyncioutils import maybe_get_event_loop_policy
from test.libregrtest.utils import print_warning
try:
import _multiprocessing, multiprocessing.process
Expand Down Expand Up @@ -84,7 +85,7 @@ def restore_urllib_requests__opener(self, opener):
urllib.request._opener = opener

def get_asyncio_events__event_loop_policy(self):
return support.maybe_get_event_loop_policy()
return maybe_get_event_loop_policy()
def restore_asyncio_events__event_loop_policy(self, policy):
asyncio.set_event_loop_policy(policy)

Expand Down
5 changes: 0 additions & 5 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
if __name__ != 'test.support':
raise ImportError('support must be imported from the test package')

import asyncio.events
import collections.abc
import contextlib
import errno
Expand Down Expand Up @@ -3255,10 +3254,6 @@ def __gt__(self, other):

SMALLEST = _SMALLEST()

def maybe_get_event_loop_policy():
"""Return the global event loop policy if one is set, else return None."""
return asyncio.events._event_loop_policy

# Helpers for testing hashing.
NHASHBITS = sys.hash_info.width # number of bits in hash() result
assert NHASHBITS in (32, 64)
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/support/asyncioutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Utilities to support asyncio in the Python regression tests."""

import asyncio.events

def maybe_get_event_loop_policy():
"""Return the global event loop policy if one is set, else return None."""
return asyncio.events._event_loop_policy
3 changes: 2 additions & 1 deletion Lib/test/test_asyncio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from asyncio import tasks
from asyncio.log import logger
from test import support
from test.support.asyncioutils import maybe_get_event_loop_policy


def data_file(filename):
Expand Down Expand Up @@ -515,7 +516,7 @@ def close_loop(loop):
else:
loop._default_executor.shutdown(wait=True)
loop.close()
policy = support.maybe_get_event_loop_policy()
policy = maybe_get_event_loop_policy()
if policy is not None:
try:
watcher = policy.get_child_watcher()
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
from operator import neg
from test import support
from test.support import (
EnvironmentVarGuard, TESTFN, check_warnings, swap_attr, unlink,
maybe_get_event_loop_policy)
EnvironmentVarGuard, TESTFN, check_warnings, swap_attr, unlink)
from test.support.asyncioutils import maybe_get_event_loop_policy
from test.support.script_helper import assert_python_ok
from unittest.mock import MagicMock, patch
try:
Expand Down