diff --git a/Lib/distutils/tests/test_bdist.py b/Lib/distutils/tests/test_bdist.py index 241fc9ad75f..5676f7f34d4 100644 --- a/Lib/distutils/tests/test_bdist.py +++ b/Lib/distutils/tests/test_bdist.py @@ -1,5 +1,4 @@ """Tests for distutils.command.bdist.""" -import os import unittest from test.support import run_unittest diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py index 0664acade82..270e91a98d0 100644 --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -12,7 +12,6 @@ from distutils.ccompiler import get_default_compiler from distutils.tests import support from test.support import run_unittest, swap_item, requires_subprocess, is_wasi from test.support.os_helper import TESTFN -from test.support.warnings_helper import check_warnings class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): diff --git a/Lib/lib2to3/tests/test_all_fixers.py b/Lib/lib2to3/tests/test_all_fixers.py index a265941490d..d0fca707248 100644 --- a/Lib/lib2to3/tests/test_all_fixers.py +++ b/Lib/lib2to3/tests/test_all_fixers.py @@ -7,7 +7,6 @@ running time. # Python imports import os.path -import sys import test.support import unittest diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 8e4bcc7c9ef..311f9db10ff 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -7,7 +7,6 @@ import itertools import bisect import copy import decimal -import functools import sys import os import pickle diff --git a/Lib/test/libregrtest/setup.py b/Lib/test/libregrtest/setup.py index cfc1b82d278..4298c922723 100644 --- a/Lib/test/libregrtest/setup.py +++ b/Lib/test/libregrtest/setup.py @@ -141,7 +141,7 @@ def _adjust_resource_limits(): """Adjust the system resource limits (ulimit) if needed.""" try: import resource - from resource import RLIMIT_NOFILE, RLIM_INFINITY + from resource import RLIMIT_NOFILE except ImportError: return fd_limit, max_fds = resource.getrlimit(RLIMIT_NOFILE) diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index f7eea88c54a..fe3ee80b8d4 100644 --- a/Lib/test/list_tests.py +++ b/Lib/test/list_tests.py @@ -3,10 +3,9 @@ Tests common to list and UserList.UserList """ import sys -import os from functools import cmp_to_key -from test import support, seq_tests +from test import seq_tests from test.support import ALWAYS_EQ, NEVER_EQ diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py index f16c7ed952c..a4f52cb20ad 100644 --- a/Lib/test/lock_tests.py +++ b/Lib/test/lock_tests.py @@ -2,7 +2,6 @@ Various tests for synchronization primitives. """ -import os import gc import sys import time diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 05d9107b28e..80d7152128c 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -29,7 +29,6 @@ if sys.platform not in ('win32', 'vxworks'): import asyncio from asyncio import coroutines from asyncio import events -from asyncio import proactor_events from asyncio import selector_events from test.test_asyncio import utils as test_utils from test import support diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py index 957cfe41eff..94d449f4791 100644 --- a/Lib/test/test_asyncio/test_runners.py +++ b/Lib/test/test_asyncio/test_runners.py @@ -1,7 +1,6 @@ import _thread import asyncio import contextvars -import gc import re import signal import threading diff --git a/Lib/test/test_asyncio/test_sock_lowlevel.py b/Lib/test/test_asyncio/test_sock_lowlevel.py index db47616d183..b829fd4cc69 100644 --- a/Lib/test/test_asyncio/test_sock_lowlevel.py +++ b/Lib/test/test_asyncio/test_sock_lowlevel.py @@ -5,7 +5,7 @@ import unittest from asyncio import proactor_events from itertools import cycle, islice -from unittest.mock import patch, Mock +from unittest.mock import Mock from test.test_asyncio import utils as test_utils from test import support from test.support import socket_helper diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 6458859db2d..69cecb3ab12 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -1,22 +1,18 @@ """Tests for tasks.py.""" import collections -import contextlib import contextvars -import functools import gc import io import random import re import sys -import textwrap import traceback import unittest from unittest import mock from types import GenericAlias import asyncio -from asyncio import coroutines from asyncio import futures from asyncio import tasks from test.test_asyncio import utils as test_utils diff --git a/Lib/test/test_asyncio/test_timeouts.py b/Lib/test/test_asyncio/test_timeouts.py index ef1ab0acb39..9801541e55b 100644 --- a/Lib/test/test_asyncio/test_timeouts.py +++ b/Lib/test/test_asyncio/test_timeouts.py @@ -4,7 +4,6 @@ import unittest import time import asyncio -from asyncio import tasks def tearDownModule(): diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py index 7ac063cfc78..913b7556be8 100644 --- a/Lib/test/test_atexit.py +++ b/Lib/test/test_atexit.py @@ -1,6 +1,5 @@ import atexit import os -import sys import textwrap import unittest from test import support diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 7087d7a471d..a2d7d0293ce 100644 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -4,7 +4,7 @@ import unittest import binascii import array import re -from test.support import bigmemtest, _1G, _4G, warnings_helper +from test.support import bigmemtest, _1G, _4G # Note: "*_hex" functions are aliases for "(un)hexlify" diff --git a/Lib/test/test_bufio.py b/Lib/test/test_bufio.py index 17151b13615..dc9a82dc635 100644 --- a/Lib/test/test_bufio.py +++ b/Lib/test/test_bufio.py @@ -1,5 +1,4 @@ import unittest -from test import support from test.support import os_helper import io # C implementation. diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 42c600dcb00..57f3648eb70 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -9,7 +9,6 @@ from unittest import mock from test import support from test.support import os_helper -from test.support import warnings_helper try: import _testcapi diff --git a/Lib/test/test_decorators.py b/Lib/test/test_decorators.py index a6baa3ad1dd..4b492178c15 100644 --- a/Lib/test/test_decorators.py +++ b/Lib/test/test_decorators.py @@ -1,4 +1,3 @@ -from test import support import unittest from types import MethodType diff --git a/Lib/test/test_defaultdict.py b/Lib/test/test_defaultdict.py index 68fc449780a..bdbe9b81e8f 100644 --- a/Lib/test/test_defaultdict.py +++ b/Lib/test/test_defaultdict.py @@ -1,9 +1,7 @@ """Unit tests for collections.defaultdict.""" -import os import copy import pickle -import tempfile import unittest from collections import defaultdict diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 9a09d8a9e3f..b5f1bd4af88 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3563,7 +3563,6 @@ order (MRO) for bases """ def test_str_of_str_subclass(self): # Testing __str__ defined in subclass of str ... import binascii - import io class octetstring(str): def __str__(self): diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 2b1e2b864fe..0bf679b4c56 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -7,7 +7,6 @@ import time import base64 import unittest import textwrap -import warnings from io import StringIO, BytesIO from itertools import chain @@ -45,7 +44,7 @@ from test.test_email import openfile, TestEmailBase # These imports are documented to work, but we are testing them using a # different path, so we import them here just to make sure they are importable. -from email.parser import FeedParser, BytesFeedParser +from email.parser import FeedParser NL = '\n' EMPTYSTRING = '' diff --git a/Lib/test/test_exception_group.py b/Lib/test/test_exception_group.py index 2cfd8738304..3ea5dff5c37 100644 --- a/Lib/test/test_exception_group.py +++ b/Lib/test/test_exception_group.py @@ -1,5 +1,4 @@ import collections.abc -import traceback import types import unittest diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index ff1a02821a5..d91308572b2 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -1,7 +1,6 @@ # Python test set -- part 5, built-in exceptions import copy -import gc import os import sys import unittest diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index d8c0fe1854e..672ec141155 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -8,7 +8,6 @@ import time import unittest from test import support -from test.support import import_helper from test.test_grammar import (VALID_UNDERSCORE_LITERALS, INVALID_UNDERSCORE_LITERALS) from math import isinf, isnan, copysign, ldexp diff --git a/Lib/test/test_flufl.py b/Lib/test/test_flufl.py index a81a4d4c8f0..fd264c926bd 100644 --- a/Lib/test/test_flufl.py +++ b/Lib/test/test_flufl.py @@ -1,6 +1,5 @@ import __future__ import unittest -from test import support class FLUFLTests(unittest.TestCase): diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 382e7dbffdd..767d2a9c1ae 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -13,7 +13,6 @@ import time import typing import unittest import unittest.mock -import os import weakref import gc from weakref import proxy @@ -21,7 +20,6 @@ import contextlib from test.support import import_helper from test.support import threading_helper -from test.support.script_helper import assert_python_ok import functools diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py index c3e8420d667..189cbdc4365 100644 --- a/Lib/test/test_future.py +++ b/Lib/test/test_future.py @@ -3,7 +3,6 @@ import __future__ import ast import unittest -from test import support from test.support import import_helper from textwrap import dedent import os diff --git a/Lib/test/test_getpath.py b/Lib/test/test_getpath.py index 5208374e200..1e46cb5780c 100644 --- a/Lib/test/test_getpath.py +++ b/Lib/test/test_getpath.py @@ -2,7 +2,6 @@ import copy import ntpath import pathlib import posixpath -import sys import unittest from test.support import verbose diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py index cb1e4505b02..1aa8e4e2897 100644 --- a/Lib/test/test_heapq.py +++ b/Lib/test/test_heapq.py @@ -4,7 +4,6 @@ import random import unittest import doctest -from test import support from test.support import import_helper from unittest import TestCase, skipUnless from operator import itemgetter diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py index f0d205a60a4..f8291c2aa32 100644 --- a/Lib/test/test_http_cookiejar.py +++ b/Lib/test/test_http_cookiejar.py @@ -4,7 +4,6 @@ import os import stat import sys import re -import test.support from test.support import os_helper from test.support import warnings_helper import time diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index ed26fa16d6e..b554bc0c799 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -10,9 +10,7 @@ import calendar import threading import socket -from test.support import (verbose, - run_with_tz, run_with_locale, cpython_only, - requires_working_socket) +from test.support import verbose, run_with_tz, run_with_locale, cpython_only from test.support import hashlib_helper from test.support import threading_helper from test.support import warnings_helper diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py index 92cb78067d0..d59b663a43e 100644 --- a/Lib/test/test_importlib/test_abc.py +++ b/Lib/test/test_importlib/test_abc.py @@ -2,7 +2,6 @@ import io import marshal import os import sys -from test import support from test.support import import_helper import types import unittest diff --git a/Lib/test/test_importlib/test_api.py b/Lib/test/test_importlib/test_api.py index e94a48fe044..b3a99dc2dd5 100644 --- a/Lib/test/test_importlib/test_api.py +++ b/Lib/test/test_importlib/test_api.py @@ -6,7 +6,6 @@ machinery = test_util.import_importlib('importlib.machinery') import os.path import sys -from test import support from test.support import import_helper from test.support import os_helper import types diff --git a/Lib/test/test_launcher.py b/Lib/test/test_launcher.py index e9f6fcb7d7f..cd7b944f98f 100644 --- a/Lib/test/test_launcher.py +++ b/Lib/test/test_launcher.py @@ -7,7 +7,6 @@ import subprocess import sys import sysconfig import tempfile -import textwrap import unittest from pathlib import Path from test import support diff --git a/Lib/test/test_lltrace.py b/Lib/test/test_lltrace.py index 5d175ce57b1..7cf89846f8a 100644 --- a/Lib/test/test_lltrace.py +++ b/Lib/test/test_lltrace.py @@ -1,5 +1,4 @@ import dis -import sys import textwrap import unittest diff --git a/Lib/test/test_mailcap.py b/Lib/test/test_mailcap.py index 8185f4a7806..819dc80a266 100644 --- a/Lib/test/test_mailcap.py +++ b/Lib/test/test_mailcap.py @@ -3,7 +3,6 @@ import os import sys import test.support import unittest -import warnings from test.support import os_helper from test.support import warnings_helper diff --git a/Lib/test/test_nis.py b/Lib/test/test_nis.py index 797c9023ad3..f327ecf3d1d 100644 --- a/Lib/test/test_nis.py +++ b/Lib/test/test_nis.py @@ -1,4 +1,3 @@ -from test import support from test.support import import_helper import unittest import warnings diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 4f632bb2f39..133abf5044d 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -15,7 +15,6 @@ import sys import sysconfig import tempfile import textwrap -import time import unittest from test import libregrtest from test import support diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py index ca2a9d9d24d..a82584d6904 100644 --- a/Lib/test/test_select.py +++ b/Lib/test/test_select.py @@ -1,5 +1,4 @@ import errno -import os import select import subprocess import sys diff --git a/Lib/test/test_shelve.py b/Lib/test/test_shelve.py index b9eb007c827..08c6562f2a2 100644 --- a/Lib/test/test_shelve.py +++ b/Lib/test/test_shelve.py @@ -1,11 +1,9 @@ import unittest import dbm import shelve -import glob import pickle import os -from test import support from test.support import os_helper from collections.abc import MutableMapping from test.test_dbm import dbm_iterator diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index dd018d6b38a..e66a2db7e9b 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -10,10 +10,9 @@ from test import support from test.support import os_helper from test.support import socket_helper from test.support import captured_stderr -from test.support.os_helper import TESTFN, EnvironmentVarGuard, change_cwd +from test.support.os_helper import TESTFN, EnvironmentVarGuard import ast import builtins -import encodings import glob import io import os diff --git a/Lib/test/test_sqlite3/__init__.py b/Lib/test/test_sqlite3/__init__.py index 099c01e3b3c..c3cab8f0acd 100644 --- a/Lib/test/test_sqlite3/__init__.py +++ b/Lib/test/test_sqlite3/__init__.py @@ -3,7 +3,6 @@ from test.support import import_helper, load_package_tests, verbose # Skip test if _sqlite3 module not installed. import_helper.import_module('_sqlite3') -import unittest import os import sqlite3 diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 1679700f592..c00d7d5b502 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -11,7 +11,6 @@ from test.support import ( from test.support.import_helper import import_module from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink, change_cwd) -from test.support.warnings_helper import check_warnings import sysconfig from sysconfig import (get_paths, get_platform, get_config_vars, diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 548914796ed..cd79024ab2c 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -1,10 +1,7 @@ import unittest -import locale -import re import subprocess import sys import os -import warnings from test import support from test.support import import_helper from test.support import os_helper diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py index 9888e631881..48e302930ff 100644 --- a/Lib/test/test_threading_local.py +++ b/Lib/test/test_threading_local.py @@ -4,7 +4,6 @@ from doctest import DocTestSuite from test import support from test.support import threading_helper import weakref -import gc # Modules under test import _thread diff --git a/Lib/test/test_tools/test_md5sum.py b/Lib/test/test_tools/test_md5sum.py index c5a230e95c2..710461f8819 100644 --- a/Lib/test/test_tools/test_md5sum.py +++ b/Lib/test/test_tools/test_md5sum.py @@ -1,6 +1,5 @@ """Tests for the md5sum script in the Tools directory.""" -import sys import os import unittest from test.support import os_helper diff --git a/Lib/test/test_tools/test_pathfix.py b/Lib/test/test_tools/test_pathfix.py index ff61935298b..aa754bc479b 100644 --- a/Lib/test/test_tools/test_pathfix.py +++ b/Lib/test/test_tools/test_pathfix.py @@ -2,7 +2,6 @@ import os import subprocess import sys import unittest -from test import support from test.support import os_helper from test.test_tools import scriptsdir, skip_if_missing diff --git a/Lib/test/test_tools/test_pindent.py b/Lib/test/test_tools/test_pindent.py index 01f13850eae..61e97fea48c 100644 --- a/Lib/test/test_tools/test_pindent.py +++ b/Lib/test/test_tools/test_pindent.py @@ -5,7 +5,6 @@ import sys import unittest import subprocess import textwrap -from test import support from test.support import os_helper from test.support.script_helper import assert_python_ok diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index ed5ddf95069..07472e29df4 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -14,7 +14,6 @@ from test.support import (Error, captured_output, cpython_only, ALWAYS_EQ, from test.support.os_helper import TESTFN, unlink from test.support.script_helper import assert_python_ok, assert_python_failure -import os import textwrap import traceback from functools import partial diff --git a/Lib/test/test_type_comments.py b/Lib/test/test_type_comments.py index 71d1430dbc9..668c1787f64 100644 --- a/Lib/test/test_type_comments.py +++ b/Lib/test/test_type_comments.py @@ -1,7 +1,6 @@ import ast import sys import unittest -from test import support funcdef = """\ diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py index b9054918780..ed2e0970bac 100644 --- a/Lib/test/test_univnewlines.py +++ b/Lib/test/test_univnewlines.py @@ -4,7 +4,6 @@ import _pyio as pyio import unittest import os import sys -from test import support from test.support import os_helper diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 46a0ab1d83e..88270b7537b 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1,7 +1,6 @@ import unittest from test import support from test.support import os_helper -from test.support import socket_helper from test.support import warnings_helper from test import test_urllib diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 37b61a780cb..e6a870fcf22 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -15,7 +15,7 @@ import struct import subprocess import sys import tempfile -from test.support import (captured_stdout, captured_stderr, requires_zlib, +from test.support import (captured_stdout, captured_stderr, skip_if_broken_multiprocessing_synchronize, verbose, requires_subprocess, is_emscripten, is_wasi, requires_venv_with_pip)