]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Revert "Remove unused imports in tests (GH-14518) (GH-14522)" (GH-14555)
authorVictor Stinner <vstinner@redhat.com>
Tue, 2 Jul 2019 12:42:39 +0000 (14:42 +0200)
committerGitHub <noreply@github.com>
Tue, 2 Jul 2019 12:42:39 +0000 (14:42 +0200)
This reverts commit e34b5f4d6483187969d5149c801d056b72ef2ddb.

48 files changed:
Lib/test/libregrtest/main.py
Lib/test/support/__init__.py
Lib/test/test_aifc.py
Lib/test/test_argparse.py
Lib/test/test_asynchat.py
Lib/test/test_asyncio/test_pep492.py
Lib/test/test_asyncio/test_sslproto.py
Lib/test/test_asyncio/test_unix_events.py
Lib/test/test_c_locale_coercion.py
Lib/test/test_capi.py
Lib/test/test_cmd_line.py
Lib/test/test_collections.py
Lib/test/test_contextlib.py
Lib/test/test_coroutines.py
Lib/test/test_docxmlrpc.py
Lib/test/test_email/test_policy.py
Lib/test/test_exceptions.py
Lib/test/test_faulthandler.py
Lib/test/test_fork1.py
Lib/test/test_frozen.py
Lib/test/test_gdb.py
Lib/test/test_generators.py
Lib/test/test_gettext.py
Lib/test/test_grammar.py
Lib/test/test_imaplib.py
Lib/test/test_import/__init__.py
Lib/test/test_importlib/test_locks.py
Lib/test/test_locale.py
Lib/test/test_netrc.py
Lib/test/test_os.py
Lib/test/test_posixpath.py
Lib/test/test_pyclbr.py
Lib/test/test_pydoc.py
Lib/test/test_queue.py
Lib/test/test_resource.py
Lib/test/test_runpy.py
Lib/test/test_sax.py
Lib/test/test_signal.py
Lib/test/test_smtplib.py
Lib/test/test_subprocess.py
Lib/test/test_thread.py
Lib/test/test_threaded_import.py
Lib/test/test_threadedtempfile.py
Lib/test/test_time.py
Lib/test/test_tokenize.py
Lib/test/test_traceback.py
Lib/test/test_utf8_mode.py
Lib/test/test_venv.py

index e2274254fdb89cd9c37d8b09ac67845394e2cbc1..1dfbe47a2fab5e40919e27959b512bcb9c4d5855 100644 (file)
@@ -587,6 +587,7 @@ class Regrtest:
 
     def cleanup(self):
         import glob
+        import shutil
 
         path = os.path.join(self.tmp_dir, 'test_python_*')
         print("Cleanup %s directory" % self.tmp_dir)
index 6d10e8b576e4893cc065494030a5511718017ef0..87bfa9f546272e8dfa847c9d0933e2440b001649 100644 (file)
@@ -5,6 +5,7 @@ if __name__ != 'test.support':
 
 import collections.abc
 import contextlib
+import datetime
 import errno
 import faulthandler
 import fnmatch
@@ -12,6 +13,7 @@ import functools
 import gc
 import importlib
 import importlib.util
+import io
 import logging.handlers
 import nntplib
 import os
index e82cfc1a469062ade07e7ee7e21f6f3a9274d74c..ff52f5b6feb8e80e5aa2eebc64ff7e82a13f7acd 100644 (file)
@@ -7,6 +7,7 @@ import io
 import sys
 import struct
 import aifc
+import warnings
 
 
 class AifcTest(audiotests.AudioWriteTests,
index 0c342e2e4e0d93f73e7b386790de2170f7795f3c..51f0effaf2ff65e71694f0db2e38d9aebf80a3dd 100644 (file)
@@ -1,5 +1,6 @@
 # Author: Steven J. Bethard <steven.bethard@gmail.com>.
 
+import codecs
 import inspect
 import os
 import shutil
index 14c0ec43d422ea5e4c3cedec79ccfb7f63d01344..1d147c741961e3a1ca4b870e1a2cf08d57273648 100644 (file)
@@ -7,6 +7,7 @@ import asyncore
 import errno
 import socket
 import sys
+import _thread as thread
 import threading
 import time
 import unittest
index ac3ae6811fb569550ba33496a263bda7b7244af6..f2d588f54445a2cc939bb2674ec5f10888efb453 100644 (file)
@@ -4,6 +4,7 @@ import sys
 import types
 import unittest
 
+from test import support
 from unittest import mock
 
 import asyncio
index 3b9c12f24ed3a71a084e8b7d2a4c01276495fd48..866ef81fb2ee3abe07d807bb7f876936da9e2e91 100644 (file)
@@ -15,6 +15,7 @@ import asyncio
 from asyncio import log
 from asyncio import protocols
 from asyncio import sslproto
+from asyncio import tasks
 from test.test_asyncio import utils as test_utils
 from test.test_asyncio import functional as func_tests
 
index 51d474cf152c9b45d1cddd491ad8563e59c76247..ec171fa83da39f23a379285ea14a00c805888c4a 100644 (file)
@@ -22,6 +22,7 @@ if sys.platform == 'win32':
 
 import asyncio
 from asyncio import log
+from asyncio import base_events
 from asyncio import events
 from asyncio import unix_events
 from test.test_asyncio import utils as test_utils
index 94391c87995a8ee37845dddfaefac3f68b59aa4b..0355547436b2f9366a4977206e7373bcba4356f1 100644 (file)
@@ -2,6 +2,7 @@
 
 import locale
 import os
+import shutil
 import subprocess
 import sys
 import sysconfig
@@ -9,8 +10,10 @@ import unittest
 from collections import namedtuple
 
 import test.support
-from test.support.script_helper import run_python_until_end
-
+from test.support.script_helper import (
+    run_python_until_end,
+    interpreter_requires_environment,
+)
 
 # Set the list of ways we expect to be able to ask for the "C" locale
 EXPECTED_C_LOCALE_EQUIVALENTS = ["C", "invalid.ascii"]
index 6eb3bd967b863c6554615c220bbbae954dbf2e96..d94ee0227c87664aa81dab310e89c339d792d0d1 100644 (file)
@@ -8,6 +8,7 @@ import random
 import re
 import subprocess
 import sys
+import sysconfig
 import textwrap
 import threading
 import time
index f90bfb067483515d31781c6097e0331f5a4c9bdb..95cdc8db7efbcc1c1c2386a82bb993c6a171981b 100644 (file)
@@ -5,6 +5,7 @@
 import os
 import subprocess
 import sys
+import sysconfig
 import tempfile
 import unittest
 from test import support
index 1aca9facda6907a8416ecca3c027ea16802f54b6..16735b815e53090dd914c85f8e1f1a2850813666 100644 (file)
@@ -3,9 +3,11 @@
 import collections
 import copy
 import doctest
+import keyword
 import operator
 import pickle
 from random import choice, randrange
+import re
 import string
 import sys
 from test import support
index ced2290288db77d3a901a3f8e2347bfbd545f809..30c2e27b3c7e77f75fe5926a11d2308775953c3d 100644 (file)
@@ -1,5 +1,6 @@
 """Unit tests for contextlib.py, and other context managers."""
 
+import asyncio
 import io
 import sys
 import tempfile
index f32320956bcc1878f13cbb3c99ecb8c9cf075189..ac24f39767385ff3bf9e16ec650a90d3b4f1873d 100644 (file)
@@ -2,6 +2,7 @@ import contextlib
 import copy
 import inspect
 import pickle
+import re
 import sys
 import types
 import unittest
index 116e626740df8545ee6af2e980f006da44f77077..f077f05f5b4f71dcb8ebc94f6f32efe0cf096be1 100644 (file)
@@ -2,6 +2,7 @@ from xmlrpc.server import DocXMLRPCServer
 import http.client
 import sys
 import threading
+from test import support
 import unittest
 
 def make_request_and_skipIf(condition, reason):
index 1e39aa062c0a4d5a1934cb58a2124107e0388d9e..0aea934df4348efa7d993b5d45dc5e4375dcfd6b 100644 (file)
@@ -1,4 +1,5 @@
 import io
+import sys
 import types
 import textwrap
 import unittest
index 0196c4d0005b44da7c5776e44fb2159ddffbb6b6..9d10df5f9425ee4241c8a020aa9fe9ceaacd0eac 100644 (file)
@@ -9,7 +9,7 @@ import weakref
 import errno
 
 from test.support import (TESTFN, captured_stderr, check_impl_detail,
-                          check_warnings, cpython_only, gc_collect,
+                          check_warnings, cpython_only, gc_collect, run_unittest,
                           no_tracing, unlink, import_module, script_helper,
                           SuppressCrashReport)
 class NaiveException(Exception):
index 5283596cebe4598665d3475d30ee0e648bb3de72..700b7ad6b8852b02da2ed572932fd3b63bcf3f4e 100644 (file)
@@ -9,6 +9,7 @@ import sysconfig
 from test import support
 from test.support import script_helper, is_android
 import tempfile
+import threading
 import unittest
 from textwrap import dedent
 
index 2ab856ff56904052f5fc77b7b161f7e6e9d1fd81..9ca9724c4c91eff80866a654608e7e22de1914de 100644 (file)
@@ -10,7 +10,8 @@ import time
 import unittest
 
 from test.fork_wait import ForkWait
-from test.support import reap_children, get_attribute, verbose
+from test.support import (reap_children, get_attribute,
+                          import_module, verbose)
 
 
 # Skip test if fork does not exist.
index 142f17d518e783e74742ea63bc62828c4cb61fa0..a7c748422b1db364dc53d697b86c388ce36103b1 100644 (file)
@@ -13,6 +13,7 @@
 import sys
 import unittest
 from test.support import captured_stdout
+from importlib import util
 
 
 class TestFrozen(unittest.TestCase):
index b78c0845b1dfd6849d28ff9fd9e9d032f639e6d2..7758e1fcd86c29b6c3e64083efbf1fb5e3c4f417 100644 (file)
@@ -3,6 +3,7 @@
 # The code for testing gdb was adapted from similar work in Unladen Swallow's
 # Lib/test/test_jit_gdb.py
 
+import locale
 import os
 import platform
 import re
index c45086562d36d0cee64ba65629a856211a21eece..7a21cb7e954ad5b999bdc8abb7a2daf0b5eac479 100644 (file)
@@ -3,6 +3,7 @@ import gc
 import pickle
 import sys
 import unittest
+import warnings
 import weakref
 import inspect
 
index fac38000e6352051392458b0916f5a8707478c01..b5ed05eab7bbe1443eca406a76e5e1bdb80affef 100644 (file)
@@ -1,6 +1,7 @@
 import os
 import base64
 import gettext
+import locale
 import unittest
 
 from test import support
index 241ac853d73cd4f87d7f1961ef415774de1289f6..88c22b89d444a3f93cb398c3fc1731904d806914 100644 (file)
@@ -4,6 +4,7 @@
 from test.support import check_syntax_error
 import inspect
 import unittest
+import sys
 # testing import *
 from sys import *
 
@@ -11,6 +12,7 @@ from sys import *
 # with import machinery
 import test.ann_module as ann_module
 import typing
+from collections import ChainMap
 from test import ann_module2
 import test
 
index 8ab532af3f0d9c7bc845c5f37c3d7c581654abb5..9305e47ee99315b63e40a655dfa74f1ec87d2383 100644 (file)
@@ -1,6 +1,7 @@
 from test import support
 
 from contextlib import contextmanager
+import errno
 import imaplib
 import os.path
 import socketserver
index 4c4f0d9efc03329d81f24d60fe7d00ef2b601052..1fc4de11e1789605cdae73b5e5caaf992e194482 100644 (file)
@@ -5,6 +5,7 @@ from importlib._bootstrap_external import _get_sourcefile
 import builtins
 import marshal
 import os
+import platform
 import py_compile
 import random
 import stat
@@ -19,9 +20,9 @@ import contextlib
 
 import test.support
 from test.support import (
-    TESTFN, forget, is_jython,
-    make_legacy_pyc, rmtree, swap_attr, swap_item, temp_umask,
-    unlink, unload, cpython_only, TESTFN_UNENCODABLE,
+    EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython,
+    make_legacy_pyc, rmtree, run_unittest, swap_attr, swap_item, temp_umask,
+    unlink, unload, create_empty_file, cpython_only, TESTFN_UNENCODABLE,
     temp_dir, DirsOnSysPath)
 from test.support import script_helper
 from test.test_importlib.util import uncache
index 21794d911ef6943b06dd99c78cf01edb8fe63983..d86172ab58373b5a55411dc79b17a14ddc906f23 100644 (file)
@@ -4,6 +4,7 @@ init = test_util.import_importlib('importlib')
 
 import sys
 import threading
+import unittest
 import weakref
 
 from test import support
index 792a15c50f9219f7c5ee10fe70d8276d4c043096..e2c2178ae6cc30103549c8dfb601d32dcb5e1ac6 100644 (file)
@@ -3,7 +3,7 @@ import unittest
 import locale
 import sys
 import codecs
-
+import warnings
 
 class BaseLocalizedTest(unittest.TestCase):
     #
index ae53988c45a6e352b0f690736b3f1a9d8e04e841..f59e5371acad3ba367d3b59999ca81f35dc5df1c 100644 (file)
@@ -1,4 +1,5 @@
 import netrc, os, unittest, sys, tempfile, textwrap
+from unittest import mock
 from test import support
 
 
index 1ec9a6a950913586022264aade8d652b772da19f..8032da0530670be190864f16fab87a54d9c283ac 100644 (file)
@@ -9,6 +9,7 @@ import contextlib
 import decimal
 import errno
 import fractions
+import getpass
 import itertools
 import locale
 import mmap
index 6bca89003a97a91408343b8716b9c60ca8e44675..e73b31cb648b227879587bd5b0b5019385380e5e 100644 (file)
@@ -1,6 +1,7 @@
 import os
 import posixpath
 import unittest
+import warnings
 from posixpath import realpath, abspath, dirname, basename
 from test import support, test_genericpath
 from test.support import FakePath
@@ -11,7 +12,6 @@ try:
 except ImportError:
     posix = None
 
-
 # An absolute path to a temporary filename for testing. We can't rely on TESTFN
 # being an absolute path, so we need this.
 
index 0489b41d7c7b30fda7c077e885f20b96473f9c0c..eaab591f74efe49676851b41cd827cc6b68a32c7 100644 (file)
@@ -3,11 +3,14 @@
    Nick Mathewson
 '''
 
+import os
 import sys
 from textwrap import dedent
 from types import FunctionType, MethodType, BuiltinFunctionType
 import pyclbr
 from unittest import TestCase, main as unittest_main
+from test import support
+from functools import partial
 
 StaticMethodType = type(staticmethod(lambda: None))
 ClassMethodType = type(classmethod(lambda c: None))
index 8e30b4c8f6759f028d03a1b1f48bf8f6c6b8756d..198cea93eb52d7a74fe8dd83ae643f5e294b1870 100644 (file)
@@ -21,6 +21,7 @@ import urllib.parse
 import xml.etree
 import xml.etree.ElementTree
 import textwrap
+import threading
 from io import StringIO
 from collections import namedtuple
 from test.support.script_helper import assert_python_ok
index c8528f97741dccb3e29e4554796775832eeb46f7..1a8d5f8856c5e86362afaa608f6c36af9de83a56 100644 (file)
@@ -1,8 +1,10 @@
 # Some simple queue module tests, plus some failure conditions
 # to ensure the Queue locks remain stable.
+import collections
 import itertools
 import queue
 import random
+import sys
 import threading
 import time
 import unittest
index 62c7963fe6999f2a58529067d4d5a050655e6879..b07eb73b2aeb71f4f763a848b44df6966d3bd2dc 100644 (file)
@@ -1,5 +1,6 @@
 import contextlib
 import sys
+import os
 import unittest
 from test import support
 import time
index 0da6f3a604301758313b2700ae274a59b6ac5505..02b4d62567e5fadbf209e9f65e1ef0a4c0cf3e5f 100644 (file)
@@ -11,7 +11,8 @@ import warnings
 from test.support import (
     forget, make_legacy_pyc, unload, verbose, no_tracing,
     create_empty_file, temp_dir)
-from test.support.script_helper import make_script, make_zip_script
+from test.support.script_helper import (
+    make_pkg, make_script, make_zip_pkg, make_zip_script)
 
 
 import runpy
index 251a03a54ddc5c860627aa15b1220cb67ba961fb..3044960a0ed165466a7a425161ba49e5e50ed98c 100644 (file)
@@ -17,6 +17,7 @@ from xml.sax.handler import feature_namespaces, feature_external_ges
 from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
 from io import BytesIO, StringIO
 import codecs
+import gc
 import os.path
 import shutil
 from urllib.error import URLError
index c3f5b148448c2d01e41962f6dbd13b8f15b5aed4..406684bdbec796e66e67db8ab035b60a7770c843 100644 (file)
@@ -5,6 +5,7 @@ import socket
 import statistics
 import subprocess
 import sys
+import threading
 import time
 import unittest
 from test import support
index 4add8fcabfd148a9433b579256810af51f9eab4e..b4149d3ef007e807c3dbc3a00a513d0a0d4cceda 100644 (file)
@@ -19,7 +19,7 @@ import threading
 
 import unittest
 from test import support, mock_socket
-from test.support import HOST
+from test.support import HOST, HOSTv4, HOSTv6
 from unittest.mock import Mock
 
 
index 36cf22a9f898668da51cf04c65cdcf9febfc065b..8419061b2a901346a6613dcbe950844ac733144c 100644 (file)
@@ -3,6 +3,7 @@ from unittest import mock
 from test import support
 import subprocess
 import sys
+import platform
 import signal
 import io
 import itertools
@@ -19,12 +20,18 @@ import gc
 import textwrap
 from test.support import FakePath
 
+try:
+    import ctypes
+except ImportError:
+    ctypes = None
+else:
+    import ctypes.util
+
 try:
     import _testcapi
 except ImportError:
     _testcapi = None
 
-
 if support.PGO:
     raise unittest.SkipTest("test is not helpful for PGO")
 
index f4eb830cf6d746967a9e0934a8adb15de543cad1..64ffe460529816505ff6344baf9c83e7e858d489 100644 (file)
@@ -4,6 +4,7 @@ import random
 from test import support
 import _thread as thread
 import time
+import sys
 import weakref
 
 from test import lock_tests
index 8607f363db21c0334330d2d431650a0f1fae7f68..035344be4b899760baa0b0bfe47fbc22369c6d5d 100644 (file)
@@ -15,7 +15,7 @@ import threading
 import unittest
 from unittest import mock
 from test.support import (
-    verbose, run_unittest, TESTFN, reap_threads,
+    verbose, import_module, run_unittest, TESTFN, reap_threads,
     forget, unlink, rmtree, start_threads)
 
 def task(N, done, done_tasks, errors):
index e1d7a10179cc1190124ae2746c61e550414febda..f3d4ba36377dacdc89281cd40d8f76044031b8be 100644 (file)
@@ -13,22 +13,19 @@ quickly. Guido reports needing to boost FILES_PER_THREAD to 500 before
 provoking a 2.0 failure under Linux.
 """
 
+NUM_THREADS = 20
+FILES_PER_THREAD = 50
+
 import tempfile
 
-from test.support import start_threads
+from test.support import start_threads, import_module
 import unittest
 import io
 import threading
 from traceback import print_exc
 
-
-NUM_THREADS = 20
-FILES_PER_THREAD = 50
-
-
 startEvent = threading.Event()
 
-
 class TempFileGreedy(threading.Thread):
     error_count = 0
     ok_count = 0
index 35952799ba6d190cb07a8c974c658752c0d107ef..4e31abf4ec8eec79af8c05086bd28b0c8f05a626 100644 (file)
@@ -9,6 +9,7 @@ import sysconfig
 import time
 import threading
 import unittest
+import warnings
 try:
     import _testcapi
 except ImportError:
index 7457a7ed043466afdc3cdf59242d29df546ffe64..d596f7db61ab9fc8af5e3084c88f1495c4c2ed97 100644 (file)
@@ -1,7 +1,7 @@
 from test import support
 from tokenize import (tokenize, _tokenize, untokenize, NUMBER, NAME, OP,
                      STRING, ENDMARKER, ENCODING, tok_name, detect_encoding,
-                     open as tokenize_open, Untokenizer,
+                     open as tokenize_open, Untokenizer, generate_tokens,
                      NEWLINE)
 from io import BytesIO
 import unittest
index 8749d095ddeec48cb7197af8df10b336920c324f..8a3aa8a8648f86c5aa1d3a42b23db1b3a413ed87 100644 (file)
@@ -110,7 +110,7 @@ class TracebackCases(unittest.TestCase):
         # Test that tracebacks are correctly printed for encoded source files:
         # - correct line number (Issue2384)
         # - respect file encoding (Issue3975)
-        import sys, subprocess
+        import tempfile, sys, subprocess, os
 
         # The spawned subprocess has its stdout redirected to a PIPE, and its
         # encoding may be different from the current interpreter, on Windows
index a7d1dc940ad6d4c61e5e1f6807a6c47751324984..06fe1979ddcc70504a033d793ee88c9cd7d6f8bd 100644 (file)
@@ -3,6 +3,7 @@ Test the implementation of the PEP 540: the UTF-8 Mode.
 """
 
 import locale
+import os
 import sys
 import textwrap
 import unittest
index 3821d9accfdffc73efaa1bcb5ad288b1044719b1..67f9f46e65e08c53cbc0ccae09fb906ef63f352b 100644 (file)
@@ -15,6 +15,7 @@ import sys
 import tempfile
 from test.support import (captured_stdout, captured_stderr, requires_zlib,
                           can_symlink, EnvironmentVarGuard, rmtree)
+import threading
 import unittest
 import venv