Revert "Remove unused imports in tests (GH-14518) (GH-14522)" (GH-14555)
This reverts commit e34b5f4d64
.
This commit is contained in:
parent
c53173aa00
commit
19b8d903b0
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,6 +7,7 @@ import io
|
|||
import sys
|
||||
import struct
|
||||
import aifc
|
||||
import warnings
|
||||
|
||||
|
||||
class AifcTest(audiotests.AudioWriteTests,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# Author: Steven J. Bethard <steven.bethard@gmail.com>.
|
||||
|
||||
import codecs
|
||||
import inspect
|
||||
import os
|
||||
import shutil
|
||||
|
|
|
@ -7,6 +7,7 @@ import asyncore
|
|||
import errno
|
||||
import socket
|
||||
import sys
|
||||
import _thread as thread
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
|
|
|
@ -4,6 +4,7 @@ import sys
|
|||
import types
|
||||
import unittest
|
||||
|
||||
from test import support
|
||||
from unittest import mock
|
||||
|
||||
import asyncio
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -8,6 +8,7 @@ import random
|
|||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import sysconfig
|
||||
import textwrap
|
||||
import threading
|
||||
import time
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import sysconfig
|
||||
import tempfile
|
||||
import unittest
|
||||
from test import support
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Unit tests for contextlib.py, and other context managers."""
|
||||
|
||||
import asyncio
|
||||
import io
|
||||
import sys
|
||||
import tempfile
|
||||
|
|
|
@ -2,6 +2,7 @@ import contextlib
|
|||
import copy
|
||||
import inspect
|
||||
import pickle
|
||||
import re
|
||||
import sys
|
||||
import types
|
||||
import unittest
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import io
|
||||
import sys
|
||||
import types
|
||||
import textwrap
|
||||
import unittest
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
import sys
|
||||
import unittest
|
||||
from test.support import captured_stdout
|
||||
from importlib import util
|
||||
|
||||
|
||||
class TestFrozen(unittest.TestCase):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,6 +3,7 @@ import gc
|
|||
import pickle
|
||||
import sys
|
||||
import unittest
|
||||
import warnings
|
||||
import weakref
|
||||
import inspect
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import base64
|
||||
import gettext
|
||||
import locale
|
||||
import unittest
|
||||
|
||||
from test import support
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from test import support
|
||||
|
||||
from contextlib import contextmanager
|
||||
import errno
|
||||
import imaplib
|
||||
import os.path
|
||||
import socketserver
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4,6 +4,7 @@ init = test_util.import_importlib('importlib')
|
|||
|
||||
import sys
|
||||
import threading
|
||||
import unittest
|
||||
import weakref
|
||||
|
||||
from test import support
|
||||
|
|
|
@ -3,7 +3,7 @@ import unittest
|
|||
import locale
|
||||
import sys
|
||||
import codecs
|
||||
|
||||
import warnings
|
||||
|
||||
class BaseLocalizedTest(unittest.TestCase):
|
||||
#
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import netrc, os, unittest, sys, tempfile, textwrap
|
||||
from unittest import mock
|
||||
from test import support
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import contextlib
|
|||
import decimal
|
||||
import errno
|
||||
import fractions
|
||||
import getpass
|
||||
import itertools
|
||||
import locale
|
||||
import mmap
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import contextlib
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from test import support
|
||||
import time
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,6 +5,7 @@ import socket
|
|||
import statistics
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
from test import support
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,6 +9,7 @@ import sysconfig
|
|||
import time
|
||||
import threading
|
||||
import unittest
|
||||
import warnings
|
||||
try:
|
||||
import _testcapi
|
||||
except ImportError:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue