summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/ctypes/test/test_parameters.py6
-rw-r--r--Lib/distutils/tests/test_bdist_rpm.py4
-rw-r--r--Lib/distutils/tests/test_build_ext.py1
-rw-r--r--Lib/distutils/tests/test_clean.py1
-rw-r--r--Lib/distutils/tests/test_config.py1
-rw-r--r--Lib/distutils/tests/test_cygwinccompiler.py3
-rw-r--r--Lib/distutils/tests/test_dep_util.py1
-rw-r--r--Lib/distutils/tests/test_file_util.py1
-rw-r--r--Lib/distutils/tests/test_install_data.py1
-rw-r--r--Lib/distutils/tests/test_install_headers.py1
-rw-r--r--Lib/distutils/tests/test_spawn.py5
-rw-r--r--Lib/lib2to3/tests/test_all_fixers.py1
-rw-r--r--Lib/lib2to3/tests/test_fixers.py3
-rw-r--r--Lib/lib2to3/tests/test_parser.py2
-rw-r--r--Lib/lib2to3/tests/test_pytree.py2
-rw-r--r--Lib/lib2to3/tests/test_refactor.py4
-rw-r--r--Lib/test/audiotests.py1
-rw-r--r--Lib/test/test__locale.py1
-rw-r--r--Lib/test/test__osx_support.py1
-rw-r--r--Lib/test/test_array.py2
-rw-r--r--Lib/test/test_asynchat.py1
-rw-r--r--Lib/test/test_bigmem.py1
-rw-r--r--Lib/test/test_binop.py2
-rw-r--r--Lib/test/test_buffer.py1
-rw-r--r--Lib/test/test_codeccallbacks.py1
-rw-r--r--Lib/test/test_codecs.py1
-rw-r--r--Lib/test/test_cprofile.py2
-rw-r--r--Lib/test/test_csv.py3
-rw-r--r--Lib/test/test_dbm_gnu.py2
-rw-r--r--Lib/test/test_dbm_ndbm.py1
-rw-r--r--Lib/test/test_devpoll.py2
-rw-r--r--Lib/test/test_doctest.py4
-rw-r--r--Lib/test/test_dynamic.py1
-rw-r--r--Lib/test/test_email/test_email.py1
-rw-r--r--Lib/test/test_email/test_headerregistry.py1
-rw-r--r--Lib/test/test_float.py1
-rw-r--r--Lib/test/test_gdb.py1
-rw-r--r--Lib/test/test_gettext.py1
-rw-r--r--Lib/test/test_idle.py1
-rw-r--r--Lib/test/test_importlib/extension/test_path_hook.py1
-rw-r--r--Lib/test/test_importlib/import_/test_packages.py1
-rw-r--r--Lib/test/test_importlib/test_locks.py1
-rw-r--r--Lib/test/test_importlib/test_namespace_pkgs.py3
-rw-r--r--Lib/test/test_mailbox.py5
-rw-r--r--Lib/test/test_mailcap.py1
-rw-r--r--Lib/test/test_math.py1
-rw-r--r--Lib/test/test_multiprocessing_main_handling.py3
-rw-r--r--Lib/test/test_pdb.py1
-rw-r--r--Lib/test/test_pep352.py1
-rw-r--r--Lib/test/test_pickletools.py1
-rw-r--r--Lib/test/test_plistlib.py1
-rw-r--r--Lib/test/test_poplib.py1
-rw-r--r--Lib/test/test_posix.py1
-rw-r--r--Lib/test/test_posixpath.py1
-rw-r--r--Lib/test/test_regrtest.py2
-rw-r--r--Lib/test/test_robotparser.py2
-rw-r--r--Lib/test/test_socket.py1
-rw-r--r--Lib/test/test_socketserver.py2
-rw-r--r--Lib/test/test_subprocess.py3
-rw-r--r--Lib/test/test_sunau.py1
-rw-r--r--Lib/test/test_telnetlib.py1
-rw-r--r--Lib/test/test_threading.py2
-rw-r--r--Lib/test/test_tools/test_gprof2html.py3
-rw-r--r--Lib/test/test_tools/test_md5sum.py2
-rw-r--r--Lib/test/test_tools/test_pdeps.py2
-rw-r--r--Lib/test/test_urllib2.py2
-rw-r--r--Lib/test/test_userstring.py1
-rw-r--r--Lib/test/test_uu.py1
-rw-r--r--Lib/test/test_venv.py1
-rw-r--r--Lib/test/test_wave.py1
-rw-r--r--Lib/test/test_weakset.py7
-rw-r--r--Lib/test/test_xml_etree_c.py2
-rw-r--r--Lib/test/test_xmlrpc.py1
-rw-r--r--Lib/test/test_xmlrpc_net.py2
-rw-r--r--Lib/test/test_zipimport_support.py1
-rw-r--r--Lib/tkinter/test/runtktests.py1
-rw-r--r--Lib/tkinter/test/test_ttk/test_functions.py1
-rw-r--r--Lib/unittest/test/testmock/testmagicmethods.py1
-rw-r--r--Lib/unittest/test/testmock/testpatch.py4
79 files changed, 23 insertions, 117 deletions
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
index 5c8d703461..363f58612d 100644
--- a/Lib/ctypes/test/test_parameters.py
+++ b/Lib/ctypes/test/test_parameters.py
@@ -49,7 +49,7 @@ class SimpleTypesTestCase(unittest.TestCase):
# XXX Replace by c_char_p tests
def test_cstrings(self):
- from ctypes import c_char_p, byref
+ from ctypes import c_char_p
# c_char_p.from_param on a Python String packs the string
# into a cparam object
@@ -68,7 +68,7 @@ class SimpleTypesTestCase(unittest.TestCase):
@need_symbol('c_wchar_p')
def test_cw_strings(self):
- from ctypes import byref, c_wchar_p
+ from ctypes import c_wchar_p
c_wchar_p.from_param("123")
@@ -98,7 +98,7 @@ class SimpleTypesTestCase(unittest.TestCase):
def test_byref_pointer(self):
# The from_param class method of POINTER(typ) classes accepts what is
# returned by byref(obj), it type(obj) == typ
- from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
+ from ctypes import c_short, c_uint, c_int, c_long, POINTER, byref
LPINT = POINTER(c_int)
LPINT.from_param(byref(c_int(42)))
diff --git a/Lib/distutils/tests/test_bdist_rpm.py b/Lib/distutils/tests/test_bdist_rpm.py
index 25c14abd32..c1a2a041ee 100644
--- a/Lib/distutils/tests/test_bdist_rpm.py
+++ b/Lib/distutils/tests/test_bdist_rpm.py
@@ -3,16 +3,12 @@
import unittest
import sys
import os
-import tempfile
-import shutil
from test.support import run_unittest
from distutils.core import Distribution
from distutils.command.bdist_rpm import bdist_rpm
from distutils.tests import support
from distutils.spawn import find_executable
-from distutils import spawn
-from distutils.errors import DistutilsExecError
SETUP_PY = """\
from distutils.core import setup
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 366ffbec9f..3d84f8b1d7 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -166,7 +166,6 @@ class BuildExtTestCase(TempdirManager,
cmd = self.build_ext(dist)
cmd.finalize_options()
- from distutils import sysconfig
py_include = sysconfig.get_python_inc()
self.assertIn(py_include, cmd.include_dirs)
diff --git a/Lib/distutils/tests/test_clean.py b/Lib/distutils/tests/test_clean.py
index df88ec1e34..c605afd860 100644
--- a/Lib/distutils/tests/test_clean.py
+++ b/Lib/distutils/tests/test_clean.py
@@ -1,7 +1,6 @@
"""Tests for distutils.command.clean."""
import os
import unittest
-import getpass
from distutils.command.clean import clean
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_config.py b/Lib/distutils/tests/test_config.py
index 0929f8a47d..d91dedd3a8 100644
--- a/Lib/distutils/tests/test_config.py
+++ b/Lib/distutils/tests/test_config.py
@@ -1,7 +1,6 @@
"""Tests for distutils.pypirc.pypirc."""
import os
import unittest
-import tempfile
from distutils.core import PyPIRCCommand
from distutils.core import Distribution
diff --git a/Lib/distutils/tests/test_cygwinccompiler.py b/Lib/distutils/tests/test_cygwinccompiler.py
index 856921679d..9dc869de4c 100644
--- a/Lib/distutils/tests/test_cygwinccompiler.py
+++ b/Lib/distutils/tests/test_cygwinccompiler.py
@@ -3,11 +3,10 @@ import unittest
import sys
import os
from io import BytesIO
-import subprocess
from test.support import run_unittest
from distutils import cygwinccompiler
-from distutils.cygwinccompiler import (CygwinCCompiler, check_config_h,
+from distutils.cygwinccompiler import (check_config_h,
CONFIG_H_OK, CONFIG_H_NOTOK,
CONFIG_H_UNCERTAIN, get_versions,
get_msvcr)
diff --git a/Lib/distutils/tests/test_dep_util.py b/Lib/distutils/tests/test_dep_util.py
index 3e1c366892..c6fae39cfb 100644
--- a/Lib/distutils/tests/test_dep_util.py
+++ b/Lib/distutils/tests/test_dep_util.py
@@ -1,7 +1,6 @@
"""Tests for distutils.dep_util."""
import unittest
import os
-import time
from distutils.dep_util import newer, newer_pairwise, newer_group
from distutils.errors import DistutilsFileError
diff --git a/Lib/distutils/tests/test_file_util.py b/Lib/distutils/tests/test_file_util.py
index a6d04f065d..03040afc79 100644
--- a/Lib/distutils/tests/test_file_util.py
+++ b/Lib/distutils/tests/test_file_util.py
@@ -1,7 +1,6 @@
"""Tests for distutils.file_util."""
import unittest
import os
-import shutil
import errno
from unittest.mock import patch
diff --git a/Lib/distutils/tests/test_install_data.py b/Lib/distutils/tests/test_install_data.py
index d73624d00b..32ab296a32 100644
--- a/Lib/distutils/tests/test_install_data.py
+++ b/Lib/distutils/tests/test_install_data.py
@@ -1,7 +1,6 @@
"""Tests for distutils.command.install_data."""
import os
import unittest
-import getpass
from distutils.command.install_data import install_data
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_install_headers.py b/Lib/distutils/tests/test_install_headers.py
index d9ed6b7fd2..2217b321e6 100644
--- a/Lib/distutils/tests/test_install_headers.py
+++ b/Lib/distutils/tests/test_install_headers.py
@@ -1,7 +1,6 @@
"""Tests for distutils.command.install_headers."""
import os
import unittest
-import getpass
from distutils.command.install_headers import install_headers
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_spawn.py b/Lib/distutils/tests/test_spawn.py
index 6c7eb20c47..f507ef7750 100644
--- a/Lib/distutils/tests/test_spawn.py
+++ b/Lib/distutils/tests/test_spawn.py
@@ -1,11 +1,10 @@
"""Tests for distutils.spawn."""
import unittest
import os
-import time
-from test.support import captured_stdout, run_unittest
+from test.support import run_unittest
from distutils.spawn import _nt_quote_args
-from distutils.spawn import spawn, find_executable
+from distutils.spawn import spawn
from distutils.errors import DistutilsExecError
from distutils.tests import support
diff --git a/Lib/lib2to3/tests/test_all_fixers.py b/Lib/lib2to3/tests/test_all_fixers.py
index 15079fe028..c0507cf3fb 100644
--- a/Lib/lib2to3/tests/test_all_fixers.py
+++ b/Lib/lib2to3/tests/test_all_fixers.py
@@ -10,7 +10,6 @@ import unittest
import test.support
# Local imports
-from lib2to3 import refactor
from . import support
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py
index def9b0e47a..b97b73ab60 100644
--- a/Lib/lib2to3/tests/test_fixers.py
+++ b/Lib/lib2to3/tests/test_fixers.py
@@ -2,12 +2,11 @@
# Python imports
import os
-import unittest
from itertools import chain
from operator import itemgetter
# Local imports
-from lib2to3 import pygram, pytree, refactor, fixer_util
+from lib2to3 import pygram, fixer_util
from lib2to3.tests import support
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py
index 46c8c54319..36eb176e5f 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -10,7 +10,7 @@ from __future__ import with_statement
# Testing imports
from . import support
-from .support import driver, test_dir
+from .support import driver
from test.support import verbose
# Python imports
diff --git a/Lib/lib2to3/tests/test_pytree.py b/Lib/lib2to3/tests/test_pytree.py
index c93aa65fc8..a611d1715e 100644
--- a/Lib/lib2to3/tests/test_pytree.py
+++ b/Lib/lib2to3/tests/test_pytree.py
@@ -11,8 +11,6 @@ especially when debugging a test.
from __future__ import with_statement
-import warnings
-
# Testing imports
from . import support
diff --git a/Lib/lib2to3/tests/test_refactor.py b/Lib/lib2to3/tests/test_refactor.py
index f30c1e8630..ab5ce72793 100644
--- a/Lib/lib2to3/tests/test_refactor.py
+++ b/Lib/lib2to3/tests/test_refactor.py
@@ -7,18 +7,14 @@ from __future__ import with_statement
import sys
import os
import codecs
-import operator
import io
import tempfile
import shutil
import unittest
-import warnings
from lib2to3 import refactor, pygram, fixer_base
from lib2to3.pgen2 import token
-from . import support
-
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
FIXER_DIR = os.path.join(TEST_DATA_DIR, "fixers")
diff --git a/Lib/test/audiotests.py b/Lib/test/audiotests.py
index e52c423b53..d3e8e9ee44 100644
--- a/Lib/test/audiotests.py
+++ b/Lib/test/audiotests.py
@@ -1,5 +1,4 @@
from test.support import findfile, TESTFN, unlink
-import unittest
import array
import io
import pickle
diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py
index 58f2f04fcd..ab4e247961 100644
--- a/Lib/test/test__locale.py
+++ b/Lib/test/test__locale.py
@@ -4,7 +4,6 @@ try:
except ImportError:
nl_langinfo = None
-import codecs
import locale
import sys
import unittest
diff --git a/Lib/test/test__osx_support.py b/Lib/test/test__osx_support.py
index ac6325a751..bcba8caa29 100644
--- a/Lib/test/test__osx_support.py
+++ b/Lib/test/test__osx_support.py
@@ -4,7 +4,6 @@ Test suite for _osx_support: shared OS X support functions.
import os
import platform
-import shutil
import stat
import sys
import unittest
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index b4f2bf868c..8fd54cc1db 100644
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -7,8 +7,6 @@ from test import support
import weakref
import pickle
import operator
-import io
-import math
import struct
import sys
import warnings
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
index 3a33fc8b2d..08090b8a06 100644
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -12,7 +12,6 @@ import socket
import sys
import time
import unittest
-import warnings
import unittest.mock
try:
import threading
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py
index 0e545950ee..9488b30290 100644
--- a/Lib/test/test_bigmem.py
+++ b/Lib/test/test_bigmem.py
@@ -14,7 +14,6 @@ from test.support import bigmemtest, _1G, _2G, _4G
import unittest
import operator
import sys
-import functools
# These tests all use one of the bigmemtest decorators to indicate how much
# memory they use and how much memory they need to be even meaningful. The
diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py
index e9dbddcd93..fc8d30fac1 100644
--- a/Lib/test/test_binop.py
+++ b/Lib/test/test_binop.py
@@ -2,7 +2,7 @@
import unittest
from test import support
-from operator import eq, ne, lt, gt, le, ge
+from operator import eq, le
from abc import ABCMeta
def gcd(a, b):
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 2eef9fc685..b83f2f107c 100644
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -16,7 +16,6 @@ import unittest
from test import support
from itertools import permutations, product
from random import randrange, sample, choice
-from sysconfig import get_config_var
import warnings
import sys, array, io
from decimal import Decimal
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py
index ee1e28a763..c8cdacf718 100644
--- a/Lib/test/test_codeccallbacks.py
+++ b/Lib/test/test_codeccallbacks.py
@@ -4,7 +4,6 @@ import sys
import test.support
import unicodedata
import unittest
-import warnings
class PosReturn:
# this can be used for configurable callbacks
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 45a1987611..d8753402ef 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -4,7 +4,6 @@ import io
import locale
import sys
import unittest
-import warnings
import encodings
from test import support
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py
index f18983fbb2..53f8917330 100644
--- a/Lib/test/test_cprofile.py
+++ b/Lib/test/test_cprofile.py
@@ -6,7 +6,7 @@ from test.support import run_unittest, TESTFN, unlink
# rip off all interesting stuff from test_profile
import cProfile
from test.test_profile import ProfileTest, regenerate_expected_output
-from test.profilee import testfunc
+
class CProfileTest(ProfileTest):
profilerclass = cProfile.Profile
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 9095f725ad..e97c9f366e 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -2,7 +2,6 @@
# csv package unit tests
import copy
-import io
import sys
import unittest
from io import StringIO
@@ -1078,7 +1077,6 @@ class TestUnicode(unittest.TestCase):
"François Pinard"]
def test_unicode_read(self):
- import io
with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
fileobj.write(",".join(self.names) + "\r\n")
fileobj.seek(0)
@@ -1087,7 +1085,6 @@ class TestUnicode(unittest.TestCase):
def test_unicode_write(self):
- import io
with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
writer = csv.writer(fileobj)
writer.writerow(self.names)
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py
index a7808f51c7..304b332869 100644
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -2,7 +2,7 @@ from test import support
gdbm = support.import_module("dbm.gnu") #skip if not supported
import unittest
import os
-from test.support import verbose, TESTFN, unlink
+from test.support import TESTFN, unlink
filename = TESTFN
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
index 13e31f2194..49f4426e4c 100644
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -1,7 +1,6 @@
from test import support
support.import_module("dbm.ndbm") #skip if not supported
import unittest
-import random
import dbm.ndbm
from dbm.ndbm import error
diff --git a/Lib/test/test_devpoll.py b/Lib/test/test_devpoll.py
index d1933e2dcb..c133c811b1 100644
--- a/Lib/test/test_devpoll.py
+++ b/Lib/test/test_devpoll.py
@@ -6,7 +6,7 @@ import os
import random
import select
import unittest
-from test.support import TESTFN, run_unittest, cpython_only
+from test.support import run_unittest, cpython_only
if not hasattr(select, 'devpoll') :
raise unittest.SkipTest('test works only on Solaris OS family')
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index f7c4806799..b9bd1353f5 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -1876,7 +1876,6 @@ if not hasattr(sys, 'gettrace') or not sys.gettrace():
To demonstrate this, we'll create a fake standard input that
captures our debugger input:
- >>> import tempfile
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
... 'print(x)', # print data defined by the example
@@ -1917,7 +1916,7 @@ if not hasattr(sys, 'gettrace') or not sys.gettrace():
... finally:
... sys.stdin = real_stdin
--Return--
- > <doctest test.test_doctest.test_pdb_set_trace[8]>(3)calls_set_trace()->None
+ > <doctest test.test_doctest.test_pdb_set_trace[7]>(3)calls_set_trace()->None
-> import pdb; pdb.set_trace()
(Pdb) print(y)
2
@@ -2804,7 +2803,6 @@ text files).
... _ = f.write(" 'abc def'\n")
... _ = f.write("\n")
... _ = f.write(' \"\"\"\n')
- ... import shutil
... rc1, out1, err1 = script_helper.assert_python_failure(
... '-m', 'doctest', fn, fn2, TERM='')
... rc2, out2, err2 = script_helper.assert_python_ok(
diff --git a/Lib/test/test_dynamic.py b/Lib/test/test_dynamic.py
index 5080ec9f79..3ae090fd66 100644
--- a/Lib/test/test_dynamic.py
+++ b/Lib/test/test_dynamic.py
@@ -1,7 +1,6 @@
# Test the most dynamic corner cases of Python's runtime semantics.
import builtins
-import contextlib
import unittest
from test.support import swap_item, swap_attr
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py
index 894b8003cd..af3fb85c56 100644
--- a/Lib/test/test_email/test_email.py
+++ b/Lib/test/test_email/test_email.py
@@ -3421,7 +3421,6 @@ Do you like this message?
class TestFeedParsers(TestEmailBase):
def parse(self, chunks):
- from email.feedparser import FeedParser
feedparser = FeedParser()
for chunk in chunks:
feedparser.feed(chunk)
diff --git a/Lib/test/test_email/test_headerregistry.py b/Lib/test/test_email/test_headerregistry.py
index 55ecdea9aa..af836dc972 100644
--- a/Lib/test/test_email/test_headerregistry.py
+++ b/Lib/test/test_email/test_headerregistry.py
@@ -1,7 +1,6 @@
import datetime
import textwrap
import unittest
-import types
from email import errors
from email import policy
from email.message import Message
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index 48f7a70c68..2e187ac64e 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -1,6 +1,5 @@
import fractions
-import math
import operator
import os
import random
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index ccef4223c2..730b628b58 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -5,7 +5,6 @@
import os
import re
-import pprint
import subprocess
import sys
import sysconfig
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index 3a94383103..d345baa26b 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -1,6 +1,5 @@
import os
import base64
-import shutil
import gettext
import unittest
diff --git a/Lib/test/test_idle.py b/Lib/test/test_idle.py
index 141e89e493..0b34e97ccc 100644
--- a/Lib/test/test_idle.py
+++ b/Lib/test/test_idle.py
@@ -1,5 +1,4 @@
import unittest
-from test import support
from test.support import import_module
# Skip test if _thread or _tkinter wasn't built or idlelib was deleted.
diff --git a/Lib/test/test_importlib/extension/test_path_hook.py b/Lib/test/test_importlib/extension/test_path_hook.py
index 8829de3c19..a4b5a64aae 100644
--- a/Lib/test/test_importlib/extension/test_path_hook.py
+++ b/Lib/test/test_importlib/extension/test_path_hook.py
@@ -2,7 +2,6 @@ from .. import util
machinery = util.import_importlib('importlib.machinery')
-import collections
import unittest
diff --git a/Lib/test/test_importlib/import_/test_packages.py b/Lib/test/test_importlib/import_/test_packages.py
index 3755b84a1a..24396044a5 100644
--- a/Lib/test/test_importlib/import_/test_packages.py
+++ b/Lib/test/test_importlib/import_/test_packages.py
@@ -1,7 +1,6 @@
from .. import util
import sys
import unittest
-import importlib
from test import support
diff --git a/Lib/test/test_importlib/test_locks.py b/Lib/test/test_importlib/test_locks.py
index df0af12d38..b2aadff289 100644
--- a/Lib/test/test_importlib/test_locks.py
+++ b/Lib/test/test_importlib/test_locks.py
@@ -3,7 +3,6 @@ from . import util as test_util
init = test_util.import_importlib('importlib')
import sys
-import time
import unittest
import weakref
diff --git a/Lib/test/test_importlib/test_namespace_pkgs.py b/Lib/test/test_importlib/test_namespace_pkgs.py
index cb49f19a6d..116eb75c15 100644
--- a/Lib/test/test_importlib/test_namespace_pkgs.py
+++ b/Lib/test/test_importlib/test_namespace_pkgs.py
@@ -1,9 +1,6 @@
import contextlib
-import importlib.abc
-import importlib.machinery
import os
import sys
-import types
import unittest
from test.test_importlib import util
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 0991f74f84..1f30fa6e8f 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -7,17 +7,12 @@ import email
import email.message
import re
import io
-import shutil
import tempfile
from test import support
import unittest
import textwrap
import mailbox
import glob
-try:
- import fcntl
-except ImportError:
- pass
class TestBase:
diff --git a/Lib/test/test_mailcap.py b/Lib/test/test_mailcap.py
index 22b2fcc4a7..623fadb8ed 100644
--- a/Lib/test/test_mailcap.py
+++ b/Lib/test/test_mailcap.py
@@ -1,6 +1,5 @@
import mailcap
import os
-import shutil
import test.support
import unittest
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 6c7b99d2d2..d0bc79065f 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -6,7 +6,6 @@ from test import support
import unittest
import math
import os
-import platform
import sys
import struct
import sysconfig
diff --git a/Lib/test/test_multiprocessing_main_handling.py b/Lib/test/test_multiprocessing_main_handling.py
index 52273ea22d..2e15cd8a6b 100644
--- a/Lib/test/test_multiprocessing_main_handling.py
+++ b/Lib/test/test_multiprocessing_main_handling.py
@@ -6,7 +6,6 @@ support.import_module('_multiprocessing')
import importlib
import importlib.machinery
-import zipimport
import unittest
import sys
import os
@@ -15,7 +14,7 @@ import py_compile
from test.support.script_helper import (
make_pkg, make_script, make_zip_pkg, make_zip_script,
- assert_python_ok, assert_python_failure, spawn_python, kill_python)
+ assert_python_ok)
# Look up which start methods are available to test
import multiprocessing
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 35044ad2a1..2cddd57643 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -558,7 +558,6 @@ def test_pdb_continue_in_bottomframe():
def pdb_invoke(method, arg):
"""Run pdb.method(arg)."""
- import pdb
getattr(pdb.Pdb(nosigint=True), method)(arg)
diff --git a/Lib/test/test_pep352.py b/Lib/test/test_pep352.py
index 7c98c460b9..27d514fe2e 100644
--- a/Lib/test/test_pep352.py
+++ b/Lib/test/test_pep352.py
@@ -1,6 +1,5 @@
import unittest
import builtins
-import warnings
import os
from platform import system as platform_system
diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py
index 80221f005c..86bebfa026 100644
--- a/Lib/test/test_pickletools.py
+++ b/Lib/test/test_pickletools.py
@@ -1,4 +1,3 @@
-import struct
import pickle
import pickletools
from test import support
diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py
index f0e9e5a9ea..12d92fa769 100644
--- a/Lib/test/test_plistlib.py
+++ b/Lib/test/test_plistlib.py
@@ -7,7 +7,6 @@ import datetime
import codecs
import binascii
import collections
-import struct
from test import support
from io import BytesIO
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py
index bceeb93ad1..7b9606d359 100644
--- a/Lib/test/test_poplib.py
+++ b/Lib/test/test_poplib.py
@@ -8,7 +8,6 @@ import asyncore
import asynchat
import socket
import os
-import time
import errno
from unittest import TestCase, skipUnless
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 28cdd90d11..6a1c82917a 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -11,7 +11,6 @@ import time
import os
import platform
import pwd
-import shutil
import stat
import tempfile
import unittest
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 8b3ce70c84..26faa48547 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -1,4 +1,3 @@
-import itertools
import os
import posixpath
import unittest
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 213853f5b1..c11408df7f 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -4,10 +4,8 @@ Tests of regrtest.py.
Note: test_regrtest cannot be run twice in parallel.
"""
-import argparse
import contextlib
import faulthandler
-import getopt
import io
import os.path
import platform
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index 90b30722da..76f4f7c614 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -2,8 +2,6 @@ import io
import unittest
import urllib.robotparser
from collections import namedtuple
-from urllib.error import URLError, HTTPError
-from urllib.request import urlopen
from test import support
from http.server import BaseHTTPRequestHandler, HTTPServer
try:
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 982a976126..a7cc1e7592 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -13,7 +13,6 @@ import queue
import sys
import os
import array
-import platform
import contextlib
from weakref import proxy
import signal
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 554c106f5d..01ac12b949 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -7,8 +7,6 @@ import os
import select
import signal
import socket
-import select
-import errno
import tempfile
import unittest
import socketserver
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 7f70fd0001..786b8cfeed 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -5,15 +5,12 @@ import subprocess
import sys
import signal
import io
-import locale
import os
import errno
import tempfile
import time
-import re
import selectors
import sysconfig
-import warnings
import select
import shutil
import gc
diff --git a/Lib/test/test_sunau.py b/Lib/test/test_sunau.py
index 0f4134e982..bc1f46c0eb 100644
--- a/Lib/test/test_sunau.py
+++ b/Lib/test/test_sunau.py
@@ -1,4 +1,3 @@
-from test.support import TESTFN
import unittest
from test import audiotests
from audioop import byteswap
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index 610377aaa6..69a9ce2a69 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -1,7 +1,6 @@
import socket
import selectors
import telnetlib
-import time
import contextlib
from test import support
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 71df14c8fd..0e7001617d 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -3,7 +3,7 @@ Tests for the threading module.
"""
import test.support
-from test.support import verbose, strip_python_stderr, import_module, cpython_only
+from test.support import verbose, import_module, cpython_only
from test.support.script_helper import assert_python_ok, assert_python_failure
import random
diff --git a/Lib/test/test_tools/test_gprof2html.py b/Lib/test/test_tools/test_gprof2html.py
index 0c294ec0c4..9489ed91f9 100644
--- a/Lib/test/test_tools/test_gprof2html.py
+++ b/Lib/test/test_tools/test_gprof2html.py
@@ -2,12 +2,11 @@
import os
import sys
-import importlib
import unittest
from unittest import mock
import tempfile
-from test.test_tools import scriptsdir, skip_if_missing, import_tool
+from test.test_tools import skip_if_missing, import_tool
skip_if_missing()
diff --git a/Lib/test/test_tools/test_md5sum.py b/Lib/test/test_tools/test_md5sum.py
index e6c83fbebc..fb565b7377 100644
--- a/Lib/test/test_tools/test_md5sum.py
+++ b/Lib/test/test_tools/test_md5sum.py
@@ -5,7 +5,7 @@ import unittest
from test import support
from test.support.script_helper import assert_python_ok, assert_python_failure
-from test.test_tools import scriptsdir, import_tool, skip_if_missing
+from test.test_tools import scriptsdir, skip_if_missing
skip_if_missing()
diff --git a/Lib/test/test_tools/test_pdeps.py b/Lib/test/test_tools/test_pdeps.py
index 0097623ded..27cbfe215d 100644
--- a/Lib/test/test_tools/test_pdeps.py
+++ b/Lib/test/test_tools/test_pdeps.py
@@ -4,7 +4,7 @@ import os
import unittest
import tempfile
-from test.test_tools import scriptsdir, skip_if_missing, import_tool
+from test.test_tools import skip_if_missing, import_tool
skip_if_missing()
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 008c751f9c..df8a891645 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -462,7 +462,7 @@ class MockHTTPHandler(urllib.request.BaseHandler):
self.requests = []
def http_open(self, req):
- import email, http.client, copy
+ import email, copy
self.requests.append(copy.deepcopy(req))
if self._count == 0:
self._count = self._count + 1
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index 35dce2c8d6..71528223d3 100644
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -1,7 +1,6 @@
# UserString is a wrapper around the native builtin string type.
# UserString instances should behave similar to builtin string objects.
-import string
import unittest
from test import string_tests
diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py
index 25fffbf993..ad2f2c59c1 100644
--- a/Lib/test/test_uu.py
+++ b/Lib/test/test_uu.py
@@ -8,7 +8,6 @@ from test import support
import sys, os
import uu
-from io import BytesIO
import io
plaintext = b"The smooth-scaled python crept over the sleeping dog\n"
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index 55bee23de3..a2842b0217 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -15,7 +15,6 @@ import sys
import tempfile
from test.support import (captured_stdout, captured_stderr,
can_symlink, EnvironmentVarGuard, rmtree)
-import textwrap
import unittest
import venv
diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py
index a67a8b009e..8666f7269c 100644
--- a/Lib/test/test_wave.py
+++ b/Lib/test/test_wave.py
@@ -1,4 +1,3 @@
-from test.support import TESTFN
import unittest
from test import audiotests
from test import support
diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py
index 3e1f4c8ed0..691b95e77c 100644
--- a/Lib/test/test_weakset.py
+++ b/Lib/test/test_weakset.py
@@ -1,11 +1,6 @@
import unittest
-from weakref import proxy, ref, WeakSet
-import operator
-import copy
+from weakref import WeakSet
import string
-from random import randrange, shuffle
-import warnings
-import collections
from collections import UserString as ustr
import gc
import contextlib
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index cd5fd6c919..87f3f27abc 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -108,7 +108,7 @@ class SizeofTest(unittest.TestCase):
struct.calcsize('8P'))
def test_main():
- from test import test_xml_etree, test_xml_etree_c
+ from test import test_xml_etree
# Run the tests specific to the C implementation
support.run_unittest(
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index cfb5964711..59f9c32da7 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -1132,7 +1132,6 @@ def captured_stdout(encoding='utf-8'):
"""A variation on support.captured_stdout() which gives a text stream
having a `buffer` attribute.
"""
- import io
orig_stdout = sys.stdout
sys.stdout = io.TextIOWrapper(io.BytesIO(), encoding=encoding)
try:
diff --git a/Lib/test/test_xmlrpc_net.py b/Lib/test/test_xmlrpc_net.py
index 1771db5f2a..ae0a28e721 100644
--- a/Lib/test/test_xmlrpc_net.py
+++ b/Lib/test/test_xmlrpc_net.py
@@ -1,6 +1,4 @@
import collections.abc
-import errno
-import socket
import unittest
from test import support
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
index 5913622f56..84d526c3db 100644
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -12,7 +12,6 @@ import zipimport
import doctest
import inspect
import linecache
-import pdb
import unittest
from test.support.script_helper import (spawn_python, kill_python, assert_python_ok,
make_script, make_zip_script)
diff --git a/Lib/tkinter/test/runtktests.py b/Lib/tkinter/test/runtktests.py
index 1ca8bde085..33dc54a137 100644
--- a/Lib/tkinter/test/runtktests.py
+++ b/Lib/tkinter/test/runtktests.py
@@ -7,7 +7,6 @@ Extensions also should live in packages following the same rule as above.
"""
import os
-import unittest
import importlib
import test.support
diff --git a/Lib/tkinter/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py
index c68a650559..a1b7cdfcd1 100644
--- a/Lib/tkinter/test/test_ttk/test_functions.py
+++ b/Lib/tkinter/test/test_ttk/test_functions.py
@@ -1,6 +1,5 @@
# -*- encoding: utf-8 -*-
import unittest
-import tkinter
from tkinter import ttk
class MockTkApp:
diff --git a/Lib/unittest/test/testmock/testmagicmethods.py b/Lib/unittest/test/testmock/testmagicmethods.py
index bb9b956bb2..24569b532d 100644
--- a/Lib/unittest/test/testmock/testmagicmethods.py
+++ b/Lib/unittest/test/testmock/testmagicmethods.py
@@ -1,5 +1,4 @@
import unittest
-import inspect
import sys
from unittest.mock import Mock, MagicMock, _magics
diff --git a/Lib/unittest/test/testmock/testpatch.py b/Lib/unittest/test/testmock/testpatch.py
index dfce3696d6..2e0c08f35f 100644
--- a/Lib/unittest/test/testmock/testpatch.py
+++ b/Lib/unittest/test/testmock/testpatch.py
@@ -10,9 +10,9 @@ from unittest.test.testmock import support
from unittest.test.testmock.support import SomeClass, is_instance
from unittest.mock import (
- NonCallableMock, CallableMixin, patch, sentinel,
+ NonCallableMock, CallableMixin, sentinel,
MagicMock, Mock, NonCallableMagicMock, patch, _patch,
- DEFAULT, call, _get_target, _patch
+ DEFAULT, call, _get_target
)