[Python-checkins] Remove unused imports in tests (GH-14518)

Victor Stinner webhook-mailer at python.org
Mon Jul 1 12:28:29 EDT 2019


https://github.com/python/cpython/commit/8f4ef3b019ce380022018587571b0f970e668de3
commit: 8f4ef3b019ce380022018587571b0f970e668de3
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-07-01T18:28:25+02:00
summary:

Remove unused imports in tests (GH-14518)

files:
M Lib/test/libregrtest/main.py
M Lib/test/support/__init__.py
M Lib/test/test__xxsubinterpreters.py
M Lib/test/test_argparse.py
M Lib/test/test_asynchat.py
M Lib/test/test_asyncio/test_events.py
M Lib/test/test_asyncio/test_pep492.py
M Lib/test/test_asyncio/test_proactor_events.py
M Lib/test/test_asyncio/test_server.py
M Lib/test/test_asyncio/test_sslproto.py
M Lib/test/test_asyncio/test_unix_events.py
M Lib/test/test_asyncio/test_windows_events.py
M Lib/test/test_audit.py
M Lib/test/test_c_locale_coercion.py
M Lib/test/test_capi.py
M Lib/test/test_cgi.py
M Lib/test/test_cmath.py
M Lib/test/test_cmd_line.py
M Lib/test/test_codeccallbacks.py
M Lib/test/test_codecs.py
M Lib/test/test_collections.py
M Lib/test/test_cprofile.py
M Lib/test/test_docxmlrpc.py
M Lib/test/test_email/test_policy.py
M Lib/test/test_embed.py
M Lib/test/test_exceptions.py
M Lib/test/test_faulthandler.py
M Lib/test/test_fork1.py
M Lib/test/test_generators.py
M Lib/test/test_gettext.py
M Lib/test/test_imaplib.py
M Lib/test/test_import/__init__.py
M Lib/test/test_importlib/test_util.py
M Lib/test/test_locale.py
M Lib/test/test_math.py
M Lib/test/test_os.py
M Lib/test/test_peepholer.py
M Lib/test/test_picklebuffer.py
M Lib/test/test_platform.py
M Lib/test/test_posixpath.py
M Lib/test/test_pyclbr.py
M Lib/test/test_pydoc.py
M Lib/test/test_runpy.py
M Lib/test/test_signal.py
M Lib/test/test_smtplib.py
M Lib/test/test_ssl.py
M Lib/test/test_string_literals.py
M Lib/test/test_subprocess.py
M Lib/test/test_sys.py
M Lib/test/test_tabnanny.py
M Lib/test/test_threaded_import.py
M Lib/test/test_threadedtempfile.py
M Lib/test/test_zipfile.py

diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 1dfbe47a2fab..e2274254fdb8 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -587,7 +587,6 @@ def create_temp_dir(self):
 
     def cleanup(self):
         import glob
-        import shutil
 
         path = os.path.join(self.tmp_dir, 'test_python_*')
         print("Cleanup %s directory" % self.tmp_dir)
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index a65de4a5abe8..611c1cc9776d 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -6,7 +6,6 @@
 import asyncio.events
 import collections.abc
 import contextlib
-import datetime
 import errno
 import faulthandler
 import fnmatch
@@ -15,7 +14,6 @@
 import glob
 import importlib
 import importlib.util
-import io
 import logging.handlers
 import nntplib
 import os
diff --git a/Lib/test/test__xxsubinterpreters.py b/Lib/test/test__xxsubinterpreters.py
index 1eece9659249..78b2030a1f6d 100644
--- a/Lib/test/test__xxsubinterpreters.py
+++ b/Lib/test/test__xxsubinterpreters.py
@@ -4,7 +4,7 @@
 import os
 import pickle
 import sys
-from textwrap import dedent, indent
+from textwrap import dedent
 import threading
 import time
 import unittest
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index bcf2cc9b26a3..9079d4bc7aa7 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -1,6 +1,5 @@
 # Author: Steven J. Bethard <steven.bethard at gmail.com>.
 
-import codecs
 import inspect
 import os
 import shutil
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
index 1d147c741961..14c0ec43d422 100644
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -7,7 +7,6 @@
 import errno
 import socket
 import sys
-import _thread as thread
 import threading
 import time
 import unittest
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 045654e87a85..e5ad72fe5ba8 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -26,8 +26,6 @@
     import tty
 
 import asyncio
-from asyncio import base_events
-from asyncio import constants
 from asyncio import coroutines
 from asyncio import events
 from asyncio import proactor_events
diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py
index 11c0ce495d52..a5cf37ded7c9 100644
--- a/Lib/test/test_asyncio/test_pep492.py
+++ b/Lib/test/test_asyncio/test_pep492.py
@@ -4,7 +4,6 @@
 import types
 import unittest
 
-from test import support
 from unittest import mock
 
 import asyncio
diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py
index 2e9995d32807..b2fd60683c57 100644
--- a/Lib/test/test_asyncio/test_proactor_events.py
+++ b/Lib/test/test_asyncio/test_proactor_events.py
@@ -4,11 +4,9 @@
 import socket
 import unittest
 import sys
-from collections import deque
 from unittest import mock
 
 import asyncio
-from asyncio import events
 from asyncio.proactor_events import BaseProactorEventLoop
 from asyncio.proactor_events import _ProactorSocketTransport
 from asyncio.proactor_events import _ProactorWritePipeTransport
diff --git a/Lib/test/test_asyncio/test_server.py b/Lib/test/test_asyncio/test_server.py
index 0e38e6c8ecd4..d47ccc027677 100644
--- a/Lib/test/test_asyncio/test_server.py
+++ b/Lib/test/test_asyncio/test_server.py
@@ -1,5 +1,4 @@
 import asyncio
-import socket
 import time
 import threading
 import unittest
diff --git a/Lib/test/test_asyncio/test_sslproto.py b/Lib/test/test_asyncio/test_sslproto.py
index 1c2285063ef6..9457bc982b06 100644
--- a/Lib/test/test_asyncio/test_sslproto.py
+++ b/Lib/test/test_asyncio/test_sslproto.py
@@ -15,7 +15,6 @@
 from asyncio import log
 from asyncio import protocols
 from asyncio import sslproto
-from asyncio import tasks
 from test.test_asyncio import utils as test_utils
 from test.test_asyncio import functional as func_tests
 
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index 462a8b3c7859..1daa870a7b27 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -22,8 +22,6 @@
 
 import asyncio
 from asyncio import log
-from asyncio import base_events
-from asyncio import events
 from asyncio import unix_events
 from test.test_asyncio import utils as test_utils
 
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
index 1e1c01d713b5..64543268b1ef 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -2,7 +2,6 @@
 import signal
 import socket
 import sys
-import subprocess
 import time
 import threading
 import unittest
@@ -12,14 +11,12 @@
     raise unittest.SkipTest('Windows only')
 
 import _overlapped
-import _testcapi
 import _winapi
 
 import asyncio
 from asyncio import windows_events
 from asyncio.streams import _StreamProtocol
 from test.test_asyncio import utils as test_utils
-from test.support.script_helper import spawn_python
 
 
 def tearDownModule():
diff --git a/Lib/test/test_audit.py b/Lib/test/test_audit.py
index 2fc41bddcb8a..41f9fae10223 100644
--- a/Lib/test/test_audit.py
+++ b/Lib/test/test_audit.py
@@ -1,7 +1,6 @@
 """Tests for sys.audit and sys.addaudithook
 """
 
-import os
 import subprocess
 import sys
 import unittest
diff --git a/Lib/test/test_c_locale_coercion.py b/Lib/test/test_c_locale_coercion.py
index 35272b5c15ac..8149e2b98bb3 100644
--- a/Lib/test/test_c_locale_coercion.py
+++ b/Lib/test/test_c_locale_coercion.py
@@ -2,7 +2,6 @@
 
 import locale
 import os
-import shutil
 import subprocess
 import sys
 import sysconfig
@@ -10,10 +9,8 @@
 from collections import namedtuple
 
 from test import support
-from test.support.script_helper import (
-    run_python_until_end,
-    interpreter_requires_environment,
-)
+from test.support.script_helper import run_python_until_end
+
 
 # Set the list of ways we expect to be able to ask for the "C" locale
 EXPECTED_C_LOCALE_EQUIVALENTS = ["C", "invalid.ascii"]
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 45fabd599159..7b35ba60b53a 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -8,7 +8,6 @@
 import re
 import subprocess
 import sys
-import sysconfig
 import textwrap
 import threading
 import time
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index b86638e1c283..092255598259 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -1,4 +1,3 @@
-from test.support import check_warnings
 import cgi
 import os
 import sys
diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py
index a00185f43dbf..668f27c8a082 100644
--- a/Lib/test/test_cmath.py
+++ b/Lib/test/test_cmath.py
@@ -6,7 +6,7 @@
 from cmath import phase, polar, rect, pi
 import platform
 import sys
-import sysconfig
+
 
 INF = float('inf')
 NAN = float('nan')
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index f7925eb795c7..497bfa9eb89d 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -5,7 +5,6 @@
 import os
 import subprocess
 import sys
-import sysconfig
 import tempfile
 import unittest
 from test import support
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py
index 585992be1f0b..243f002c4eca 100644
--- a/Lib/test/test_codeccallbacks.py
+++ b/Lib/test/test_codeccallbacks.py
@@ -1,10 +1,10 @@
 import codecs
 import html.entities
 import sys
-import test.support
 import unicodedata
 import unittest
 
+
 class PosReturn:
     # this can be used for configurable callbacks
 
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 4317dfceb039..b187ca650dc6 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -29,7 +29,7 @@ def check(input, expect):
 
 # On small versions of Windows like Windows IoT or Windows Nano Server not all codepages are present
 def is_code_page_present(cp):
-    from ctypes import POINTER, WINFUNCTYPE, windll, WinError, Structure, WinDLL
+    from ctypes import POINTER, WINFUNCTYPE, WinDLL
     from ctypes.wintypes import BOOL, UINT, BYTE, WCHAR, UINT, DWORD
 
     MAX_LEADBYTES = 12  # 5 ranges, 2 bytes ea., 0 term.
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index e2d04d5b4761..e532be6eeaf0 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -13,7 +13,7 @@
 import types
 import unittest
 
-from collections import namedtuple, Counter, OrderedDict, _count_elements, _tuplegetter
+from collections import namedtuple, Counter, OrderedDict, _count_elements
 from collections import UserDict, UserString, UserList
 from collections import ChainMap
 from collections import deque
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py
index 5c70037f39a2..4ec769885292 100644
--- a/Lib/test/test_cprofile.py
+++ b/Lib/test/test_cprofile.py
@@ -6,7 +6,7 @@
 # rip off all interesting stuff from test_profile
 import cProfile
 from test.test_profile import ProfileTest, regenerate_expected_output
-from test.support.script_helper import assert_python_failure, assert_python_ok
+from test.support.script_helper import assert_python_failure
 from test import support
 
 
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
index f077f05f5b4f..116e626740df 100644
--- a/Lib/test/test_docxmlrpc.py
+++ b/Lib/test/test_docxmlrpc.py
@@ -2,7 +2,6 @@
 import http.client
 import sys
 import threading
-from test import support
 import unittest
 
 def make_request_and_skipIf(condition, reason):
diff --git a/Lib/test/test_email/test_policy.py b/Lib/test/test_email/test_policy.py
index 0aea934df434..1e39aa062c0a 100644
--- a/Lib/test/test_email/test_policy.py
+++ b/Lib/test/test_email/test_policy.py
@@ -1,5 +1,4 @@
 import io
-import sys
 import types
 import textwrap
 import unittest
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 9c78aa059fc3..e1cf4be50668 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -5,7 +5,6 @@
 from collections import namedtuple
 import json
 import os
-import platform
 import re
 import subprocess
 import sys
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index d7e11d2d30a8..10c1e076464e 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -9,7 +9,7 @@
 import errno
 
 from test.support import (TESTFN, captured_stderr, check_impl_detail,
-                          check_warnings, cpython_only, gc_collect, run_unittest,
+                          check_warnings, cpython_only, gc_collect,
                           no_tracing, unlink, import_module, script_helper,
                           SuppressCrashReport)
 from test import support
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index f0be91844ffa..1cf20db1c7ff 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -9,7 +9,6 @@
 from test import support
 from test.support import script_helper, is_android
 import tempfile
-import threading
 import unittest
 from textwrap import dedent
 
diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py
index 9ca9724c4c91..2ab856ff5690 100644
--- a/Lib/test/test_fork1.py
+++ b/Lib/test/test_fork1.py
@@ -10,8 +10,7 @@
 import unittest
 
 from test.fork_wait import ForkWait
-from test.support import (reap_children, get_attribute,
-                          import_module, verbose)
+from test.support import reap_children, get_attribute, verbose
 
 
 # Skip test if fork does not exist.
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index a34e4ec2eda7..f8d86da5e2f5 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -3,7 +3,6 @@
 import pickle
 import sys
 import unittest
-import warnings
 import weakref
 import inspect
 
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index 9d1a96b8b0d1..baf300b05724 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -2,7 +2,6 @@
 import base64
 import contextlib
 import gettext
-import locale
 import unittest
 
 from test import support
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 9305e47ee993..8ab532af3f0d 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -1,7 +1,6 @@
 from test import support
 
 from contextlib import contextmanager
-import errno
 import imaplib
 import os.path
 import socketserver
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index 84cd0da94b36..50406d9aa1d9 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -5,7 +5,6 @@
 import builtins
 import marshal
 import os
-import platform
 import py_compile
 import random
 import shutil
@@ -23,9 +22,9 @@
 
 import test.support
 from test.support import (
-    EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython,
-    make_legacy_pyc, rmtree, run_unittest, swap_attr, swap_item, temp_umask,
-    unlink, unload, create_empty_file, cpython_only, TESTFN_UNENCODABLE,
+    TESTFN, forget, is_jython,
+    make_legacy_pyc, rmtree, swap_attr, swap_item, temp_umask,
+    unlink, unload, cpython_only, TESTFN_UNENCODABLE,
     temp_dir, DirsOnSysPath)
 from test.support import script_helper
 from test.test_importlib.util import uncache
diff --git a/Lib/test/test_importlib/test_util.py b/Lib/test/test_importlib/test_util.py
index db0899aff6b9..0350a5a5cc05 100644
--- a/Lib/test/test_importlib/test_util.py
+++ b/Lib/test/test_importlib/test_util.py
@@ -4,7 +4,6 @@
 machinery = util.import_importlib('importlib.machinery')
 importlib_util = util.import_importlib('importlib.util')
 
-import contextlib
 import importlib.util
 import os
 import pathlib
diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py
index e2c2178ae6cc..792a15c50f92 100644
--- a/Lib/test/test_locale.py
+++ b/Lib/test/test_locale.py
@@ -3,7 +3,7 @@
 import locale
 import sys
 import codecs
-import warnings
+
 
 class BaseLocalizedTest(unittest.TestCase):
     #
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 362d09370d45..393cdaff1818 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -12,7 +12,7 @@
 import random
 import struct
 import sys
-import sysconfig
+
 
 eps = 1E-05
 NAN = float('nan')
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 784000a2eb36..b2cd4cca5f21 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -9,7 +9,6 @@
 import decimal
 import errno
 import fractions
-import getpass
 import itertools
 import locale
 import mmap
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index b5f85bd55973..c90a53210a93 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -1,10 +1,9 @@
 import dis
 import unittest
-import types
-import textwrap
 
 from test.bytecode_helper import BytecodeTestCase
 
+
 def count_instr_recursively(f, opname):
     count = 0
     for instr in dis.get_instructions(f):
diff --git a/Lib/test/test_picklebuffer.py b/Lib/test/test_picklebuffer.py
index 7e72157fd022..97981c882e82 100644
--- a/Lib/test/test_picklebuffer.py
+++ b/Lib/test/test_picklebuffer.py
@@ -5,7 +5,6 @@
 
 import gc
 from pickle import PickleBuffer
-import sys
 import weakref
 import unittest
 
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 8b64923e174c..3084663a8fad 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -2,13 +2,12 @@
 import platform
 import subprocess
 import sys
-import sysconfig
-import tempfile
 import unittest
 from unittest import mock
 
 from test import support
 
+
 class PlatformTest(unittest.TestCase):
     def clear_caches(self):
         platform._platform_cache.clear()
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 983e2dd6ff27..4d3d8976d604 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -1,7 +1,6 @@
 import os
 import posixpath
 import unittest
-import warnings
 from posixpath import realpath, abspath, dirname, basename
 from test import support, test_genericpath
 from test.support import FakePath
@@ -12,6 +11,7 @@
 except ImportError:
     posix = None
 
+
 # An absolute path to a temporary filename for testing. We can't rely on TESTFN
 # being an absolute path, so we need this.
 
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 531304021312..4385271cd0f2 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -3,15 +3,13 @@
    Nick Mathewson
 '''
 
-import os
 import sys
 from textwrap import dedent
 from types import FunctionType, MethodType, BuiltinFunctionType
 import pyclbr
 from unittest import TestCase, main as unittest_main
-from test import support
 from test.test_importlib import util as test_importlib_util
-from functools import partial
+
 
 StaticMethodType = type(staticmethod(lambda: None))
 ClassMethodType = type(classmethod(lambda c: None))
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index 6efdeb047c21..c80477c50f09 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -21,7 +21,6 @@
 import xml.etree
 import xml.etree.ElementTree
 import textwrap
-import threading
 from io import StringIO
 from collections import namedtuple
 from test.support.script_helper import assert_python_ok
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py
index 800b483b7e15..f00308611163 100644
--- a/Lib/test/test_runpy.py
+++ b/Lib/test/test_runpy.py
@@ -11,8 +11,7 @@
 from test.support import (
     forget, make_legacy_pyc, unload, verbose, no_tracing,
     create_empty_file, temp_dir)
-from test.support.script_helper import (
-    make_pkg, make_script, make_zip_pkg, make_zip_script)
+from test.support.script_helper import make_script, make_zip_script
 
 
 import runpy
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index 063b35ca230f..d41e94b07f43 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -6,7 +6,6 @@
 import statistics
 import subprocess
 import sys
-import threading
 import time
 import unittest
 from test import support
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index fdcf6f219256..f1332e9ef782 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -19,7 +19,7 @@
 
 import unittest
 from test import support, mock_socket
-from test.support import HOST, HOSTv4, HOSTv6
+from test.support import HOST
 from test.support import threading_setup, threading_cleanup, join_thread
 from unittest.mock import Mock
 
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index d83ee2cc974d..ef1723903a15 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -26,7 +26,7 @@
 
 ssl = support.import_module("ssl")
 
-from ssl import TLSVersion, _TLSContentType, _TLSMessageType, _TLSAlertType
+from ssl import TLSVersion, _TLSContentType, _TLSMessageType
 
 Py_DEBUG = hasattr(sys, 'gettotalrefcount')
 Py_DEBUG_WIN32 = Py_DEBUG and sys.platform == 'win32'
@@ -4601,7 +4601,6 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
 
 def test_main(verbose=False):
     if support.verbose:
-        import warnings
         plats = {
             'Mac': platform.mac_ver,
             'Windows': platform.win32_ver,
diff --git a/Lib/test/test_string_literals.py b/Lib/test/test_string_literals.py
index 048f40d90a4b..5961d591c448 100644
--- a/Lib/test/test_string_literals.py
+++ b/Lib/test/test_string_literals.py
@@ -31,7 +31,6 @@
 import sys
 import shutil
 import tempfile
-import warnings
 import unittest
 
 
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 6b8acb258ee3..e58d0925df3b 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -3,7 +3,6 @@
 from test import support
 import subprocess
 import sys
-import platform
 import signal
 import io
 import itertools
@@ -20,18 +19,12 @@
 import textwrap
 from test.support import FakePath
 
-try:
-    import ctypes
-except ImportError:
-    ctypes = None
-else:
-    import ctypes.util
-
 try:
     import _testcapi
 except ImportError:
     _testcapi = None
 
+
 if support.PGO:
     raise unittest.SkipTest("test is not helpful for PGO")
 
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 8852aaef9437..9961dee754c6 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -3,7 +3,6 @@
 import builtins
 import codecs
 import gc
-import io
 import locale
 import operator
 import os
diff --git a/Lib/test/test_tabnanny.py b/Lib/test/test_tabnanny.py
index 81549d14ae2b..95840d6ac0c5 100644
--- a/Lib/test/test_tabnanny.py
+++ b/Lib/test/test_tabnanny.py
@@ -7,7 +7,6 @@
 from unittest import mock
 import errno
 import os
-import sys
 import tabnanny
 import tokenize
 import tempfile
diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py
index 035344be4b89..8607f363db21 100644
--- a/Lib/test/test_threaded_import.py
+++ b/Lib/test/test_threaded_import.py
@@ -15,7 +15,7 @@
 import unittest
 from unittest import mock
 from test.support import (
-    verbose, import_module, run_unittest, TESTFN, reap_threads,
+    verbose, run_unittest, TESTFN, reap_threads,
     forget, unlink, rmtree, start_threads)
 
 def task(N, done, done_tasks, errors):
diff --git a/Lib/test/test_threadedtempfile.py b/Lib/test/test_threadedtempfile.py
index f3d4ba36377d..e1d7a10179cc 100644
--- a/Lib/test/test_threadedtempfile.py
+++ b/Lib/test/test_threadedtempfile.py
@@ -13,19 +13,22 @@
 provoking a 2.0 failure under Linux.
 """
 
-NUM_THREADS = 20
-FILES_PER_THREAD = 50
-
 import tempfile
 
-from test.support import start_threads, import_module
+from test.support import start_threads
 import unittest
 import io
 import threading
 from traceback import print_exc
 
+
+NUM_THREADS = 20
+FILES_PER_THREAD = 50
+
+
 startEvent = threading.Event()
 
+
 class TempFileGreedy(threading.Thread):
     error_count = 0
     ok_count = 0
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index bf5bb4d0f13e..19b550f80187 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -4,9 +4,7 @@
 import os
 import pathlib
 import posixpath
-import shutil
 import struct
-import tempfile
 import time
 import unittest
 import zipfile



More information about the Python-checkins mailing list