From 3e9751819ad13a965e8be13c1e5bc5a6811fe6b8 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Mon, 11 Dec 2017 10:04:40 -0500 Subject: [PATCH] bpo-32273: Move asyncio.test_utils to test.test_asyncio (#4785) --- Lib/test/test_asyncio/test_base_events.py | 15 +++------------ Lib/test/test_asyncio/test_events.py | 4 +--- Lib/test/test_asyncio/test_futures.py | 7 ++----- Lib/test/test_asyncio/test_locks.py | 2 +- Lib/test/test_asyncio/test_pep492.py | 7 ++----- Lib/test/test_asyncio/test_proactor_events.py | 2 +- Lib/test/test_asyncio/test_queues.py | 2 +- Lib/test/test_asyncio/test_selector_events.py | 2 +- Lib/test/test_asyncio/test_sslproto.py | 2 +- Lib/test/test_asyncio/test_streams.py | 2 +- Lib/test/test_asyncio/test_subprocess.py | 8 +++----- Lib/test/test_asyncio/test_tasks.py | 15 +++------------ Lib/test/test_asyncio/test_unix_events.py | 2 +- Lib/test/test_asyncio/test_windows_events.py | 2 +- Lib/test/test_asyncio/test_windows_utils.py | 7 +------ .../test_utils.py => test/test_asyncio/utils.py} | 10 +++++----- .../2017-12-10-19-14-55.bpo-32273.5KKlCv.rst | 1 + 17 files changed, 29 insertions(+), 61 deletions(-) rename Lib/{asyncio/test_utils.py => test/test_asyncio/utils.py} (98%) create mode 100644 Misc/NEWS.d/next/Library/2017-12-10-19-14-55.bpo-32273.5KKlCv.rst diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index 6561a9df779..8b08ed16634 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -14,18 +14,9 @@ from unittest import mock import asyncio from asyncio import base_events from asyncio import constants -from asyncio import test_utils -try: - from test import support -except ImportError: - from asyncio import test_support as support -try: - from test.support.script_helper import assert_python_ok -except ImportError: - try: - from test.script_helper import assert_python_ok - except ImportError: - from asyncio.test_support import assert_python_ok +from test.test_asyncio import utils as test_utils +from test import support +from test.support.script_helper import assert_python_ok MOCK_ANY = mock.ANY diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 01300246fda..39d5bb54a9d 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -3,7 +3,6 @@ import collections.abc import concurrent.futures import functools -import gc import io import os import platform @@ -30,8 +29,7 @@ import asyncio from asyncio import coroutines from asyncio import proactor_events from asyncio import selector_events -from asyncio import sslproto -from asyncio import test_utils +from test.test_asyncio import utils as test_utils try: from test import support except ImportError: diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py index 4320a901f49..444d1df02be 100644 --- a/Lib/test/test_asyncio/test_futures.py +++ b/Lib/test/test_asyncio/test_futures.py @@ -9,12 +9,9 @@ import unittest from unittest import mock import asyncio -from asyncio import test_utils from asyncio import futures -try: - from test import support -except ImportError: - from asyncio import test_support as support +from test.test_asyncio import utils as test_utils +from test import support def _fakefunc(f): diff --git a/Lib/test/test_asyncio/test_locks.py b/Lib/test/test_asyncio/test_locks.py index 78d80ecf4f3..3c5069778b5 100644 --- a/Lib/test/test_asyncio/test_locks.py +++ b/Lib/test/test_asyncio/test_locks.py @@ -5,7 +5,7 @@ from unittest import mock import re import asyncio -from asyncio import test_utils +from test.test_asyncio import utils as test_utils STR_RGX_REPR = ( r'^<(?P.*?) object at (?P
.*?)' diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py index 442577017d9..8dd0c25e7cf 100644 --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -3,14 +3,11 @@ import types import unittest -try: - from test import support -except ImportError: - from asyncio import test_support as support +from test import support from unittest import mock import asyncio -from asyncio import test_utils +from test.test_asyncio import utils as test_utils class BaseTest(test_utils.TestCase): diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py index def08b96ab0..7ccc6814b2e 100644 --- a/Lib/test/test_asyncio/test_proactor_events.py +++ b/Lib/test/test_asyncio/test_proactor_events.py @@ -9,7 +9,7 @@ from asyncio.proactor_events import BaseProactorEventLoop from asyncio.proactor_events import _ProactorSocketTransport from asyncio.proactor_events import _ProactorWritePipeTransport from asyncio.proactor_events import _ProactorDuplexPipeTransport -from asyncio import test_utils +from test.test_asyncio import utils as test_utils def close_transport(transport): diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 3b66d616f8e..8d78546318a 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -4,7 +4,7 @@ import unittest from unittest import mock import asyncio -from asyncio import test_utils +from test.test_asyncio import utils as test_utils class _QueueTestBase(test_utils.TestCase): diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py index 616eb6f2630..24feb30e3d5 100644 --- a/Lib/test/test_asyncio/test_selector_events.py +++ b/Lib/test/test_asyncio/test_selector_events.py @@ -11,11 +11,11 @@ except ImportError: ssl = None import asyncio -from asyncio import test_utils from asyncio.selector_events import BaseSelectorEventLoop from asyncio.selector_events import _SelectorTransport from asyncio.selector_events import _SelectorSocketTransport from asyncio.selector_events import _SelectorDatagramTransport +from test.test_asyncio import utils as test_utils MOCK_ANY = mock.ANY diff --git a/Lib/test/test_asyncio/test_sslproto.py b/Lib/test/test_asyncio/test_sslproto.py index f573ae8fe77..7650fe6bd46 100644 --- a/Lib/test/test_asyncio/test_sslproto.py +++ b/Lib/test/test_asyncio/test_sslproto.py @@ -11,7 +11,7 @@ except ImportError: import asyncio from asyncio import log from asyncio import sslproto -from asyncio import test_utils +from test.test_asyncio import utils as test_utils @unittest.skipIf(ssl is None, 'No ssl module') diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py index 1927d731281..7a0762cfa3b 100644 --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -16,7 +16,7 @@ except ImportError: ssl = None import asyncio -from asyncio import test_utils +from test.test_asyncio import utils as test_utils class StreamReaderTests(test_utils.TestCase): diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py index ad4bb149559..81b08d6c292 100644 --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -7,11 +7,9 @@ from unittest import mock import asyncio from asyncio import base_subprocess from asyncio import subprocess -from asyncio import test_utils -try: - from test import support -except ImportError: - from asyncio import test_support as support +from test.test_asyncio import utils as test_utils +from test import support + if sys.platform != 'win32': from asyncio import unix_events diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index cdc882a9bee..071481dbc26 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -17,18 +17,9 @@ import asyncio from asyncio import coroutines from asyncio import futures from asyncio import tasks -from asyncio import test_utils -try: - from test import support -except ImportError: - from asyncio import test_support as support -try: - from test.support.script_helper import assert_python_ok -except ImportError: - try: - from test.script_helper import assert_python_ok - except ImportError: - from asyncio.test_support import assert_python_ok +from test.test_asyncio import utils as test_utils +from test import support +from test.support.script_helper import assert_python_ok @asyncio.coroutine diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 6746b34fe2c..e13cc3749da 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -21,8 +21,8 @@ if sys.platform == 'win32': import asyncio from asyncio import log -from asyncio import test_utils from asyncio import unix_events +from test.test_asyncio import utils as test_utils MOCK_ANY = mock.ANY diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py index de6fe120612..fdba636f207 100644 --- a/Lib/test/test_asyncio/test_windows_events.py +++ b/Lib/test/test_asyncio/test_windows_events.py @@ -11,8 +11,8 @@ import _overlapped import _winapi import asyncio -from asyncio import test_utils from asyncio import windows_events +from test.test_asyncio import utils as test_utils class UpperProto(asyncio.Protocol): diff --git a/Lib/test/test_asyncio/test_windows_utils.py b/Lib/test/test_asyncio/test_windows_utils.py index 952f95e5730..9fc38586ab0 100644 --- a/Lib/test/test_asyncio/test_windows_utils.py +++ b/Lib/test/test_asyncio/test_windows_utils.py @@ -1,10 +1,8 @@ """Tests for window_utils""" -import socket import sys import unittest import warnings -from unittest import mock if sys.platform != 'win32': raise unittest.SkipTest('Windows only') @@ -13,10 +11,7 @@ import _overlapped import _winapi from asyncio import windows_utils -try: - from test import support -except ImportError: - from asyncio import test_support as support +from test import support class PipeTests(unittest.TestCase): diff --git a/Lib/asyncio/test_utils.py b/Lib/test/test_asyncio/utils.py similarity index 98% rename from Lib/asyncio/test_utils.py rename to Lib/test/test_asyncio/utils.py index 231916970c7..560db9f562d 100644 --- a/Lib/asyncio/test_utils.py +++ b/Lib/test/test_asyncio/utils.py @@ -26,11 +26,11 @@ try: except ImportError: # pragma: no cover ssl = None -from . import base_events -from . import events -from . import futures -from . import tasks -from .log import logger +from asyncio import base_events +from asyncio import events +from asyncio import futures +from asyncio import tasks +from asyncio.log import logger from test import support diff --git a/Misc/NEWS.d/next/Library/2017-12-10-19-14-55.bpo-32273.5KKlCv.rst b/Misc/NEWS.d/next/Library/2017-12-10-19-14-55.bpo-32273.5KKlCv.rst new file mode 100644 index 00000000000..3bbec8f6e34 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-12-10-19-14-55.bpo-32273.5KKlCv.rst @@ -0,0 +1 @@ +Move asyncio.test_utils to test.test_asyncio.