From e437a10d15ddfd21d406e591acccf12ff443194e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 24 Apr 2016 21:41:02 +0300 Subject: Issue #23277: Remove unused imports in tests. --- Lib/ctypes/test/test_parameters.py | 6 +++--- Lib/distutils/tests/test_bdist_rpm.py | 4 ---- Lib/distutils/tests/test_build_ext.py | 1 - Lib/distutils/tests/test_clean.py | 1 - Lib/distutils/tests/test_config.py | 1 - Lib/distutils/tests/test_cygwinccompiler.py | 3 +-- Lib/distutils/tests/test_dep_util.py | 1 - Lib/distutils/tests/test_file_util.py | 1 - Lib/distutils/tests/test_install_data.py | 1 - Lib/distutils/tests/test_install_headers.py | 1 - Lib/distutils/tests/test_spawn.py | 5 ++--- Lib/lib2to3/tests/test_all_fixers.py | 1 - Lib/lib2to3/tests/test_fixers.py | 3 +-- Lib/lib2to3/tests/test_parser.py | 2 +- Lib/lib2to3/tests/test_pytree.py | 2 -- Lib/lib2to3/tests/test_refactor.py | 4 ---- Lib/test/audiotests.py | 1 - Lib/test/test__locale.py | 1 - Lib/test/test__osx_support.py | 1 - Lib/test/test_array.py | 2 -- Lib/test/test_asynchat.py | 1 - Lib/test/test_bigmem.py | 1 - Lib/test/test_binop.py | 2 +- Lib/test/test_buffer.py | 1 - Lib/test/test_codeccallbacks.py | 1 - Lib/test/test_codecs.py | 1 - Lib/test/test_cprofile.py | 2 +- Lib/test/test_csv.py | 3 --- Lib/test/test_dbm_gnu.py | 2 +- Lib/test/test_dbm_ndbm.py | 1 - Lib/test/test_devpoll.py | 2 +- Lib/test/test_doctest.py | 4 +--- Lib/test/test_dynamic.py | 1 - Lib/test/test_email/test_email.py | 1 - Lib/test/test_email/test_headerregistry.py | 1 - Lib/test/test_float.py | 1 - Lib/test/test_gdb.py | 1 - Lib/test/test_gettext.py | 1 - Lib/test/test_idle.py | 1 - Lib/test/test_importlib/extension/test_path_hook.py | 1 - Lib/test/test_importlib/import_/test_packages.py | 1 - Lib/test/test_importlib/test_locks.py | 1 - Lib/test/test_importlib/test_namespace_pkgs.py | 3 --- Lib/test/test_mailbox.py | 5 ----- Lib/test/test_mailcap.py | 1 - Lib/test/test_math.py | 1 - Lib/test/test_multiprocessing_main_handling.py | 3 +-- Lib/test/test_pdb.py | 1 - Lib/test/test_pep352.py | 1 - Lib/test/test_pickletools.py | 1 - Lib/test/test_plistlib.py | 1 - Lib/test/test_poplib.py | 1 - Lib/test/test_posix.py | 1 - Lib/test/test_posixpath.py | 1 - Lib/test/test_regrtest.py | 2 -- Lib/test/test_robotparser.py | 2 -- Lib/test/test_socket.py | 1 - Lib/test/test_socketserver.py | 2 -- Lib/test/test_subprocess.py | 3 --- Lib/test/test_sunau.py | 1 - Lib/test/test_telnetlib.py | 1 - Lib/test/test_threading.py | 2 +- Lib/test/test_tools/test_gprof2html.py | 3 +-- Lib/test/test_tools/test_md5sum.py | 2 +- Lib/test/test_tools/test_pdeps.py | 2 +- Lib/test/test_urllib2.py | 2 +- Lib/test/test_userstring.py | 1 - Lib/test/test_uu.py | 1 - Lib/test/test_venv.py | 1 - Lib/test/test_wave.py | 1 - Lib/test/test_weakset.py | 7 +------ Lib/test/test_xml_etree_c.py | 2 +- Lib/test/test_xmlrpc.py | 1 - Lib/test/test_xmlrpc_net.py | 2 -- Lib/test/test_zipimport_support.py | 1 - Lib/tkinter/test/runtktests.py | 1 - Lib/tkinter/test/test_ttk/test_functions.py | 1 - Lib/unittest/test/testmock/testmagicmethods.py | 1 - Lib/unittest/test/testmock/testpatch.py | 4 ++-- 79 files changed, 23 insertions(+), 117 deletions(-) diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py index 5c8d703..363f586 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 25c14ab..c1a2a04 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 366ffbe..3d84f8b 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 df88ec1..c605afd 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 0929f8a..d91dedd 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 8569216..9dc869d 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 3e1c366..c6fae39 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 a6d04f0..03040af 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 d73624d..32ab296 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 d9ed6b7..2217b32 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 6c7eb20..f507ef7 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 15079fe..c0507cf 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 def9b0e..b97b73a 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 46c8c54..36eb176 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 c93aa65..a611d17 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 f30c1e8..ab5ce727 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 e52c423..d3e8e9e 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 58f2f04..ab4e247 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 ac6325a..bcba8ca 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 b4f2bf8..8fd54cc 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 3a33fc8..08090b8 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 0e54595..9488b30 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 e9dbddc..fc8d30f 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 2eef9fc..b83f2f1 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 ee1e28a..c8cdacf 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 45a1987..d875340 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 f18983f..53f8917 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 9095f72..e97c9f3 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 a7808f5..304b332 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 13e31f2..49f4426 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 d1933e2..c133c81 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 f7c4806..b9bd135 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-- - > (3)calls_set_trace()->None + > (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 5080ec9..3ae090f 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 894b800..af3fb85 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 55ecdea..af836dc 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 48f7a70..2e187ac 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 ccef422..730b628 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 3a94383..d345baa 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 141e89e..0b34e97 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 8829de3..a4b5a64 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 3755b84..2439604 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 df0af12..b2aadff 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 cb49f19..116eb75 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 0991f74..1f30fa6 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 22b2fcc..623fadb 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 6c7b99d..d0bc790 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 52273ea..2e15cd8 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 35044ad..2cddd57 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 7c98c46..27d514f 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 80221f0..86bebfa 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 f0e9e5a..12d92fa 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 bceeb93..7b9606d 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 28cdd90..6a1c829 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 8b3ce70..26faa48 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 213853f..c11408d 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 90b3072..76f4f7c 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 982a976..a7cc1e7 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 554c106..01ac12b 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 7f70fd0..786b8cf 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 0f4134e..bc1f46c 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 610377a..69a9ce2 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 71df14c..0e70016 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 0c294ec..9489ed9 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 e6c83fb..fb565b7 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 0097623..27cbfe2 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 008c751..df8a891 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 35dce2c..7152822 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 25fffbf..ad2f2c5 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 55bee23..a2842b0 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 a67a8b0..8666f72 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 3e1f4c8..691b95e 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 cd5fd6c..87f3f27 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 cfb5964..59f9c32 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 1771db5..ae0a28e 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 5913622..84d526c 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 1ca8bde..33dc54a 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 c68a650..a1b7cdf 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 bb9b956..24569b5 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 dfce369..2e0c08f 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 ) -- cgit v0.12