Skip to content

Commit 3ceb4b8

Browse files
authored
pythongh-84623: Remove unused imports in tests (python#93772)
1 parent 65ff27c commit 3ceb4b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+8
-65
lines changed

Lib/distutils/tests/test_bdist.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Tests for distutils.command.bdist."""
2-
import os
32
import unittest
43
from test.support import run_unittest
54

Lib/distutils/tests/test_sysconfig.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from distutils.tests import support
1313
from test.support import run_unittest, swap_item, requires_subprocess, is_wasi
1414
from test.support.os_helper import TESTFN
15-
from test.support.warnings_helper import check_warnings
1615

1716

1817
class SysconfigTestCase(support.EnvironGuard, unittest.TestCase):

Lib/lib2to3/tests/test_all_fixers.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
# Python imports
99
import os.path
10-
import sys
1110
import test.support
1211
import unittest
1312

Lib/test/datetimetester.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import bisect
88
import copy
99
import decimal
10-
import functools
1110
import sys
1211
import os
1312
import pickle

Lib/test/libregrtest/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def _adjust_resource_limits():
141141
"""Adjust the system resource limits (ulimit) if needed."""
142142
try:
143143
import resource
144-
from resource import RLIMIT_NOFILE, RLIM_INFINITY
144+
from resource import RLIMIT_NOFILE
145145
except ImportError:
146146
return
147147
fd_limit, max_fds = resource.getrlimit(RLIMIT_NOFILE)

Lib/test/list_tests.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
"""
44

55
import sys
6-
import os
76
from functools import cmp_to_key
87

9-
from test import support, seq_tests
8+
from test import seq_tests
109
from test.support import ALWAYS_EQ, NEVER_EQ
1110

1211

Lib/test/lock_tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Various tests for synchronization primitives.
33
"""
44

5-
import os
65
import gc
76
import sys
87
import time

Lib/test/test_asyncio/test_events.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import asyncio
3030
from asyncio import coroutines
3131
from asyncio import events
32-
from asyncio import proactor_events
3332
from asyncio import selector_events
3433
from test.test_asyncio import utils as test_utils
3534
from test import support

Lib/test/test_asyncio/test_runners.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import _thread
22
import asyncio
33
import contextvars
4-
import gc
54
import re
65
import signal
76
import threading

Lib/test/test_asyncio/test_sock_lowlevel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from asyncio import proactor_events
77
from itertools import cycle, islice
8-
from unittest.mock import patch, Mock
8+
from unittest.mock import Mock
99
from test.test_asyncio import utils as test_utils
1010
from test import support
1111
from test.support import socket_helper

Lib/test/test_asyncio/test_tasks.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
"""Tests for tasks.py."""
22

33
import collections
4-
import contextlib
54
import contextvars
6-
import functools
75
import gc
86
import io
97
import random
108
import re
119
import sys
12-
import textwrap
1310
import traceback
1411
import unittest
1512
from unittest import mock
1613
from types import GenericAlias
1714

1815
import asyncio
19-
from asyncio import coroutines
2016
from asyncio import futures
2117
from asyncio import tasks
2218
from test.test_asyncio import utils as test_utils

Lib/test/test_asyncio/test_timeouts.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import time
55

66
import asyncio
7-
from asyncio import tasks
87

98

109
def tearDownModule():

Lib/test/test_atexit.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import atexit
22
import os
3-
import sys
43
import textwrap
54
import unittest
65
from test import support

Lib/test/test_binascii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import binascii
55
import array
66
import re
7-
from test.support import bigmemtest, _1G, _4G, warnings_helper
7+
from test.support import bigmemtest, _1G, _4G
88

99

1010
# Note: "*_hex" functions are aliases for "(un)hexlify"

Lib/test/test_bufio.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import unittest
2-
from test import support
32
from test.support import os_helper
43

54
import io # C implementation.

Lib/test/test_codecs.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from test import support
1111
from test.support import os_helper
12-
from test.support import warnings_helper
1312

1413
try:
1514
import _testcapi

Lib/test/test_decorators.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from test import support
21
import unittest
32
from types import MethodType
43

Lib/test/test_defaultdict.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""Unit tests for collections.defaultdict."""
22

3-
import os
43
import copy
54
import pickle
6-
import tempfile
75
import unittest
86

97
from collections import defaultdict

Lib/test/test_descr.py

-1
Original file line numberDiff line numberDiff line change
@@ -3563,7 +3563,6 @@ class MyInt(int):
35633563
def test_str_of_str_subclass(self):
35643564
# Testing __str__ defined in subclass of str ...
35653565
import binascii
3566-
import io
35673566

35683567
class octetstring(str):
35693568
def __str__(self):

Lib/test/test_email/test_email.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import base64
88
import unittest
99
import textwrap
10-
import warnings
1110

1211
from io import StringIO, BytesIO
1312
from itertools import chain
@@ -45,7 +44,7 @@
4544

4645
# These imports are documented to work, but we are testing them using a
4746
# different path, so we import them here just to make sure they are importable.
48-
from email.parser import FeedParser, BytesFeedParser
47+
from email.parser import FeedParser
4948

5049
NL = '\n'
5150
EMPTYSTRING = ''

Lib/test/test_exception_group.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import collections.abc
2-
import traceback
32
import types
43
import unittest
54

Lib/test/test_exceptions.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Python test set -- part 5, built-in exceptions
22

33
import copy
4-
import gc
54
import os
65
import sys
76
import unittest

Lib/test/test_float.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import unittest
99

1010
from test import support
11-
from test.support import import_helper
1211
from test.test_grammar import (VALID_UNDERSCORE_LITERALS,
1312
INVALID_UNDERSCORE_LITERALS)
1413
from math import isinf, isnan, copysign, ldexp

Lib/test/test_flufl.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import __future__
22
import unittest
3-
from test import support
43

54

65
class FLUFLTests(unittest.TestCase):

Lib/test/test_functools.py

-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
import typing
1414
import unittest
1515
import unittest.mock
16-
import os
1716
import weakref
1817
import gc
1918
from weakref import proxy
2019
import contextlib
2120

2221
from test.support import import_helper
2322
from test.support import threading_helper
24-
from test.support.script_helper import assert_python_ok
2523

2624
import functools
2725

Lib/test/test_future.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import __future__
44
import ast
55
import unittest
6-
from test import support
76
from test.support import import_helper
87
from textwrap import dedent
98
import os

Lib/test/test_getpath.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import ntpath
33
import pathlib
44
import posixpath
5-
import sys
65
import unittest
76

87
from test.support import verbose

Lib/test/test_heapq.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import unittest
55
import doctest
66

7-
from test import support
87
from test.support import import_helper
98
from unittest import TestCase, skipUnless
109
from operator import itemgetter

Lib/test/test_http_cookiejar.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import stat
55
import sys
66
import re
7-
import test.support
87
from test.support import os_helper
98
from test.support import warnings_helper
109
import time

Lib/test/test_imaplib.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
import threading
1111
import socket
1212

13-
from test.support import (verbose,
14-
run_with_tz, run_with_locale, cpython_only,
15-
requires_working_socket)
13+
from test.support import verbose, run_with_tz, run_with_locale, cpython_only
1614
from test.support import hashlib_helper
1715
from test.support import threading_helper
1816
from test.support import warnings_helper

Lib/test/test_importlib/test_abc.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import marshal
33
import os
44
import sys
5-
from test import support
65
from test.support import import_helper
76
import types
87
import unittest

Lib/test/test_importlib/test_api.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import os.path
88
import sys
9-
from test import support
109
from test.support import import_helper
1110
from test.support import os_helper
1211
import types

Lib/test/test_launcher.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import sys
88
import sysconfig
99
import tempfile
10-
import textwrap
1110
import unittest
1211
from pathlib import Path
1312
from test import support

Lib/test/test_lltrace.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import dis
2-
import sys
32
import textwrap
43
import unittest
54

Lib/test/test_mailcap.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys
44
import test.support
55
import unittest
6-
import warnings
76
from test.support import os_helper
87
from test.support import warnings_helper
98

Lib/test/test_nis.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from test import support
21
from test.support import import_helper
32
import unittest
43
import warnings

Lib/test/test_regrtest.py

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import sysconfig
1616
import tempfile
1717
import textwrap
18-
import time
1918
import unittest
2019
from test import libregrtest
2120
from test import support

Lib/test/test_select.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import errno
2-
import os
32
import select
43
import subprocess
54
import sys

Lib/test/test_shelve.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import unittest
22
import dbm
33
import shelve
4-
import glob
54
import pickle
65
import os
76

8-
from test import support
97
from test.support import os_helper
108
from collections.abc import MutableMapping
119
from test.test_dbm import dbm_iterator

Lib/test/test_site.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
from test.support import os_helper
1111
from test.support import socket_helper
1212
from test.support import captured_stderr
13-
from test.support.os_helper import TESTFN, EnvironmentVarGuard, change_cwd
13+
from test.support.os_helper import TESTFN, EnvironmentVarGuard
1414
import ast
1515
import builtins
16-
import encodings
1716
import glob
1817
import io
1918
import os

Lib/test/test_sqlite3/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Skip test if _sqlite3 module not installed.
44
import_helper.import_module('_sqlite3')
55

6-
import unittest
76
import os
87
import sqlite3
98

Lib/test/test_sysconfig.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from test.support.import_helper import import_module
1212
from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink,
1313
change_cwd)
14-
from test.support.warnings_helper import check_warnings
1514

1615
import sysconfig
1716
from sysconfig import (get_paths, get_platform, get_config_vars,

Lib/test/test_tcl.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import unittest
2-
import locale
3-
import re
42
import subprocess
53
import sys
64
import os
7-
import warnings
85
from test import support
96
from test.support import import_helper
107
from test.support import os_helper

Lib/test/test_threading_local.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from test import support
55
from test.support import threading_helper
66
import weakref
7-
import gc
87

98
# Modules under test
109
import _thread

Lib/test/test_tools/test_md5sum.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Tests for the md5sum script in the Tools directory."""
22

3-
import sys
43
import os
54
import unittest
65
from test.support import os_helper

0 commit comments

Comments
 (0)