gh-84623: Remove unused imports in tests (#93772)

This commit is contained in:
Victor Stinner 2022-06-13 16:56:03 +02:00 committed by GitHub
parent 65ff27c7d3
commit 3ceb4b8d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 8 additions and 65 deletions

View File

@ -1,5 +1,4 @@
"""Tests for distutils.command.bdist.""" """Tests for distutils.command.bdist."""
import os
import unittest import unittest
from test.support import run_unittest from test.support import run_unittest

View File

@ -12,7 +12,6 @@ from distutils.ccompiler import get_default_compiler
from distutils.tests import support from distutils.tests import support
from test.support import run_unittest, swap_item, requires_subprocess, is_wasi from test.support import run_unittest, swap_item, requires_subprocess, is_wasi
from test.support.os_helper import TESTFN from test.support.os_helper import TESTFN
from test.support.warnings_helper import check_warnings
class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): class SysconfigTestCase(support.EnvironGuard, unittest.TestCase):

View File

@ -7,7 +7,6 @@ running time.
# Python imports # Python imports
import os.path import os.path
import sys
import test.support import test.support
import unittest import unittest

View File

@ -7,7 +7,6 @@ import itertools
import bisect import bisect
import copy import copy
import decimal import decimal
import functools
import sys import sys
import os import os
import pickle import pickle

View File

@ -141,7 +141,7 @@ def _adjust_resource_limits():
"""Adjust the system resource limits (ulimit) if needed.""" """Adjust the system resource limits (ulimit) if needed."""
try: try:
import resource import resource
from resource import RLIMIT_NOFILE, RLIM_INFINITY from resource import RLIMIT_NOFILE
except ImportError: except ImportError:
return return
fd_limit, max_fds = resource.getrlimit(RLIMIT_NOFILE) fd_limit, max_fds = resource.getrlimit(RLIMIT_NOFILE)

View File

@ -3,10 +3,9 @@ Tests common to list and UserList.UserList
""" """
import sys import sys
import os
from functools import cmp_to_key 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 from test.support import ALWAYS_EQ, NEVER_EQ

View File

@ -2,7 +2,6 @@
Various tests for synchronization primitives. Various tests for synchronization primitives.
""" """
import os
import gc import gc
import sys import sys
import time import time

View File

@ -29,7 +29,6 @@ if sys.platform not in ('win32', 'vxworks'):
import asyncio import asyncio
from asyncio import coroutines from asyncio import coroutines
from asyncio import events from asyncio import events
from asyncio import proactor_events
from asyncio import selector_events from asyncio import selector_events
from test.test_asyncio import utils as test_utils from test.test_asyncio import utils as test_utils
from test import support from test import support

View File

@ -1,7 +1,6 @@
import _thread import _thread
import asyncio import asyncio
import contextvars import contextvars
import gc
import re import re
import signal import signal
import threading import threading

View File

@ -5,7 +5,7 @@ import unittest
from asyncio import proactor_events from asyncio import proactor_events
from itertools import cycle, islice 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.test_asyncio import utils as test_utils
from test import support from test import support
from test.support import socket_helper from test.support import socket_helper

View File

@ -1,22 +1,18 @@
"""Tests for tasks.py.""" """Tests for tasks.py."""
import collections import collections
import contextlib
import contextvars import contextvars
import functools
import gc import gc
import io import io
import random import random
import re import re
import sys import sys
import textwrap
import traceback import traceback
import unittest import unittest
from unittest import mock from unittest import mock
from types import GenericAlias from types import GenericAlias
import asyncio import asyncio
from asyncio import coroutines
from asyncio import futures from asyncio import futures
from asyncio import tasks from asyncio import tasks
from test.test_asyncio import utils as test_utils from test.test_asyncio import utils as test_utils

View File

@ -4,7 +4,6 @@ import unittest
import time import time
import asyncio import asyncio
from asyncio import tasks
def tearDownModule(): def tearDownModule():

View File

@ -1,6 +1,5 @@
import atexit import atexit
import os import os
import sys
import textwrap import textwrap
import unittest import unittest
from test import support from test import support

View File

@ -4,7 +4,7 @@ import unittest
import binascii import binascii
import array import array
import re 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" # Note: "*_hex" functions are aliases for "(un)hexlify"

View File

@ -1,5 +1,4 @@
import unittest import unittest
from test import support
from test.support import os_helper from test.support import os_helper
import io # C implementation. import io # C implementation.

View File

@ -9,7 +9,6 @@ from unittest import mock
from test import support from test import support
from test.support import os_helper from test.support import os_helper
from test.support import warnings_helper
try: try:
import _testcapi import _testcapi

View File

@ -1,4 +1,3 @@
from test import support
import unittest import unittest
from types import MethodType from types import MethodType

View File

@ -1,9 +1,7 @@
"""Unit tests for collections.defaultdict.""" """Unit tests for collections.defaultdict."""
import os
import copy import copy
import pickle import pickle
import tempfile
import unittest import unittest
from collections import defaultdict from collections import defaultdict

View File

@ -3563,7 +3563,6 @@ order (MRO) for bases """
def test_str_of_str_subclass(self): def test_str_of_str_subclass(self):
# Testing __str__ defined in subclass of str ... # Testing __str__ defined in subclass of str ...
import binascii import binascii
import io
class octetstring(str): class octetstring(str):
def __str__(self): def __str__(self):

View File

@ -7,7 +7,6 @@ import time
import base64 import base64
import unittest import unittest
import textwrap import textwrap
import warnings
from io import StringIO, BytesIO from io import StringIO, BytesIO
from itertools import chain 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 # 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. # 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' NL = '\n'
EMPTYSTRING = '' EMPTYSTRING = ''

View File

@ -1,5 +1,4 @@
import collections.abc import collections.abc
import traceback
import types import types
import unittest import unittest

View File

@ -1,7 +1,6 @@
# Python test set -- part 5, built-in exceptions # Python test set -- part 5, built-in exceptions
import copy import copy
import gc
import os import os
import sys import sys
import unittest import unittest

View File

@ -8,7 +8,6 @@ import time
import unittest import unittest
from test import support from test import support
from test.support import import_helper
from test.test_grammar import (VALID_UNDERSCORE_LITERALS, from test.test_grammar import (VALID_UNDERSCORE_LITERALS,
INVALID_UNDERSCORE_LITERALS) INVALID_UNDERSCORE_LITERALS)
from math import isinf, isnan, copysign, ldexp from math import isinf, isnan, copysign, ldexp

View File

@ -1,6 +1,5 @@
import __future__ import __future__
import unittest import unittest
from test import support
class FLUFLTests(unittest.TestCase): class FLUFLTests(unittest.TestCase):

View File

@ -13,7 +13,6 @@ import time
import typing import typing
import unittest import unittest
import unittest.mock import unittest.mock
import os
import weakref import weakref
import gc import gc
from weakref import proxy from weakref import proxy
@ -21,7 +20,6 @@ import contextlib
from test.support import import_helper from test.support import import_helper
from test.support import threading_helper from test.support import threading_helper
from test.support.script_helper import assert_python_ok
import functools import functools

View File

@ -3,7 +3,6 @@
import __future__ import __future__
import ast import ast
import unittest import unittest
from test import support
from test.support import import_helper from test.support import import_helper
from textwrap import dedent from textwrap import dedent
import os import os

View File

@ -2,7 +2,6 @@ import copy
import ntpath import ntpath
import pathlib import pathlib
import posixpath import posixpath
import sys
import unittest import unittest
from test.support import verbose from test.support import verbose

View File

@ -4,7 +4,6 @@ import random
import unittest import unittest
import doctest import doctest
from test import support
from test.support import import_helper from test.support import import_helper
from unittest import TestCase, skipUnless from unittest import TestCase, skipUnless
from operator import itemgetter from operator import itemgetter

View File

@ -4,7 +4,6 @@ import os
import stat import stat
import sys import sys
import re import re
import test.support
from test.support import os_helper from test.support import os_helper
from test.support import warnings_helper from test.support import warnings_helper
import time import time

View File

@ -10,9 +10,7 @@ import calendar
import threading import threading
import socket import socket
from test.support import (verbose, from test.support import verbose, run_with_tz, run_with_locale, cpython_only
run_with_tz, run_with_locale, cpython_only,
requires_working_socket)
from test.support import hashlib_helper from test.support import hashlib_helper
from test.support import threading_helper from test.support import threading_helper
from test.support import warnings_helper from test.support import warnings_helper

View File

@ -2,7 +2,6 @@ import io
import marshal import marshal
import os import os
import sys import sys
from test import support
from test.support import import_helper from test.support import import_helper
import types import types
import unittest import unittest

View File

@ -6,7 +6,6 @@ machinery = test_util.import_importlib('importlib.machinery')
import os.path import os.path
import sys import sys
from test import support
from test.support import import_helper from test.support import import_helper
from test.support import os_helper from test.support import os_helper
import types import types

View File

@ -7,7 +7,6 @@ import subprocess
import sys import sys
import sysconfig import sysconfig
import tempfile import tempfile
import textwrap
import unittest import unittest
from pathlib import Path from pathlib import Path
from test import support from test import support

View File

@ -1,5 +1,4 @@
import dis import dis
import sys
import textwrap import textwrap
import unittest import unittest

View File

@ -3,7 +3,6 @@ import os
import sys import sys
import test.support import test.support
import unittest import unittest
import warnings
from test.support import os_helper from test.support import os_helper
from test.support import warnings_helper from test.support import warnings_helper

View File

@ -1,4 +1,3 @@
from test import support
from test.support import import_helper from test.support import import_helper
import unittest import unittest
import warnings import warnings

View File

@ -15,7 +15,6 @@ import sys
import sysconfig import sysconfig
import tempfile import tempfile
import textwrap import textwrap
import time
import unittest import unittest
from test import libregrtest from test import libregrtest
from test import support from test import support

View File

@ -1,5 +1,4 @@
import errno import errno
import os
import select import select
import subprocess import subprocess
import sys import sys

View File

@ -1,11 +1,9 @@
import unittest import unittest
import dbm import dbm
import shelve import shelve
import glob
import pickle import pickle
import os import os
from test import support
from test.support import os_helper from test.support import os_helper
from collections.abc import MutableMapping from collections.abc import MutableMapping
from test.test_dbm import dbm_iterator from test.test_dbm import dbm_iterator

View File

@ -10,10 +10,9 @@ from test import support
from test.support import os_helper from test.support import os_helper
from test.support import socket_helper from test.support import socket_helper
from test.support import captured_stderr 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 ast
import builtins import builtins
import encodings
import glob import glob
import io import io
import os import os

View File

@ -3,7 +3,6 @@ from test.support import import_helper, load_package_tests, verbose
# Skip test if _sqlite3 module not installed. # Skip test if _sqlite3 module not installed.
import_helper.import_module('_sqlite3') import_helper.import_module('_sqlite3')
import unittest
import os import os
import sqlite3 import sqlite3

View File

@ -11,7 +11,6 @@ from test.support import (
from test.support.import_helper import import_module from test.support.import_helper import import_module
from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink, from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink,
change_cwd) change_cwd)
from test.support.warnings_helper import check_warnings
import sysconfig import sysconfig
from sysconfig import (get_paths, get_platform, get_config_vars, from sysconfig import (get_paths, get_platform, get_config_vars,

View File

@ -1,10 +1,7 @@
import unittest import unittest
import locale
import re
import subprocess import subprocess
import sys import sys
import os import os
import warnings
from test import support from test import support
from test.support import import_helper from test.support import import_helper
from test.support import os_helper from test.support import os_helper

View File

@ -4,7 +4,6 @@ from doctest import DocTestSuite
from test import support from test import support
from test.support import threading_helper from test.support import threading_helper
import weakref import weakref
import gc
# Modules under test # Modules under test
import _thread import _thread

View File

@ -1,6 +1,5 @@
"""Tests for the md5sum script in the Tools directory.""" """Tests for the md5sum script in the Tools directory."""
import sys
import os import os
import unittest import unittest
from test.support import os_helper from test.support import os_helper

View File

@ -2,7 +2,6 @@ import os
import subprocess import subprocess
import sys import sys
import unittest import unittest
from test import support
from test.support import os_helper from test.support import os_helper
from test.test_tools import scriptsdir, skip_if_missing from test.test_tools import scriptsdir, skip_if_missing

View File

@ -5,7 +5,6 @@ import sys
import unittest import unittest
import subprocess import subprocess
import textwrap import textwrap
from test import support
from test.support import os_helper from test.support import os_helper
from test.support.script_helper import assert_python_ok from test.support.script_helper import assert_python_ok

View File

@ -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.os_helper import TESTFN, unlink
from test.support.script_helper import assert_python_ok, assert_python_failure from test.support.script_helper import assert_python_ok, assert_python_failure
import os
import textwrap import textwrap
import traceback import traceback
from functools import partial from functools import partial

View File

@ -1,7 +1,6 @@
import ast import ast
import sys import sys
import unittest import unittest
from test import support
funcdef = """\ funcdef = """\

View File

@ -4,7 +4,6 @@ import _pyio as pyio
import unittest import unittest
import os import os
import sys import sys
from test import support
from test.support import os_helper from test.support import os_helper

View File

@ -1,7 +1,6 @@
import unittest import unittest
from test import support from test import support
from test.support import os_helper from test.support import os_helper
from test.support import socket_helper
from test.support import warnings_helper from test.support import warnings_helper
from test import test_urllib from test import test_urllib

View File

@ -15,7 +15,7 @@ import struct
import subprocess import subprocess
import sys import sys
import tempfile 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, skip_if_broken_multiprocessing_synchronize, verbose,
requires_subprocess, is_emscripten, is_wasi, requires_subprocess, is_emscripten, is_wasi,
requires_venv_with_pip) requires_venv_with_pip)