diff options
author | Georg Brandl <georg@python.org> | 2010-02-07 17:03:15 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-02-07 17:03:15 (GMT) |
commit | a4f46e129294c686ef1effdd89c459bd9a624e6d (patch) | |
tree | d8cf84a6f4a9a1a3e7ad10f8daec0ecd5f5674cb /Lib/test | |
parent | dc3694bee021480980d5b66a93f69ce137ee5be4 (diff) | |
download | cpython-a4f46e129294c686ef1effdd89c459bd9a624e6d.zip cpython-a4f46e129294c686ef1effdd89c459bd9a624e6d.tar.gz cpython-a4f46e129294c686ef1effdd89c459bd9a624e6d.tar.bz2 |
Remove unused imports in test modules.
Diffstat (limited to 'Lib/test')
74 files changed, 40 insertions, 135 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index db93db1..f125152 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -149,7 +149,6 @@ option '-uall,-bsddb'. import cStringIO import getopt -import itertools import json import os import random @@ -448,8 +447,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, if use_mp: from threading import Thread - from Queue import Queue, Empty - from subprocess import Popen, PIPE, STDOUT + from Queue import Queue + from subprocess import Popen, PIPE from collections import deque debug_output_pat = re.compile(r"\[\d+ refs\]$") pending = deque() diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py index 0f67731..2fc128f 100644 --- a/Lib/test/test__locale.py +++ b/Lib/test/test__locale.py @@ -1,4 +1,4 @@ -from test.test_support import verbose, run_unittest +from test.test_support import run_unittest from _locale import (setlocale, LC_NUMERIC, localeconv, Error) try: from _locale import (RADIXCHAR, THOUSEP, nl_langinfo) diff --git a/Lib/test/test_abstract_numbers.py b/Lib/test/test_abstract_numbers.py index 8f1fdd7..925f8cf 100644 --- a/Lib/test/test_abstract_numbers.py +++ b/Lib/test/test_abstract_numbers.py @@ -1,10 +1,8 @@ """Unit tests for numbers.py.""" import math -import operator import unittest from numbers import Complex, Real, Rational, Integral -from numbers import Number from test import test_support class TestNumbers(unittest.TestCase): diff --git a/Lib/test/test_applesingle.py b/Lib/test/test_applesingle.py index 5a8201c..1beffe0 100644 --- a/Lib/test/test_applesingle.py +++ b/Lib/test/test_applesingle.py @@ -7,9 +7,7 @@ import struct MacOS = test_support.import_module('MacOS') # The following should exist if MacOS does. -import macostools import applesingle -import Carbon.File AS_MAGIC=0x00051600 AS_VERSION=0x00020000 diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py index a5fa494..d1ee0a1 100755 --- a/Lib/test/test_bsddb.py +++ b/Lib/test/test_bsddb.py @@ -3,7 +3,6 @@ Adapted to unittest format and expanded scope by Raymond Hettinger """ import os, sys -import copy import unittest from test import test_support diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index ac843c3..ac9d85d 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1,12 +1,12 @@ # Python test set -- built-in functions import platform -import test.test_support, unittest +import unittest from test.test_support import fcmp, have_unicode, TESTFN, unlink, \ - run_unittest, run_with_locale + run_unittest from operator import neg -import sys, warnings, cStringIO, random, fractions, UserDict +import sys, warnings, cStringIO, random, UserDict warnings.filterwarnings("ignore", "hex../oct.. of negative int", FutureWarning, __name__) warnings.filterwarnings("ignore", "integer argument expected", diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py index e53deff..8b5c4bf 100755 --- a/Lib/test/test_cmath.py +++ b/Lib/test/test_cmath.py @@ -1,7 +1,6 @@ from test.test_support import run_unittest from test.test_math import parse_testfile, test_file import unittest -import os, sys import cmath, math from cmath import phase, polar, rect, pi diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 6c146f3..be3b70e 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -2,7 +2,6 @@ # All tests are executed with environment variables ignored # See test_cmd_line_script.py for testing of script execution -import os import test.test_support, unittest import sys from test.script_helper import spawn_python, kill_python, python_exit_code diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index e1a7f91..099471f 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -3,9 +3,8 @@ import unittest import os import os.path -import sys import test.test_support -from test.script_helper import (spawn_python, kill_python, run_python, +from test.script_helper import (run_python, temp_dir, make_script, compile_script, make_pkg, make_zip_script, make_zip_pkg) diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 809fd86..77ce7ed 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -6,7 +6,6 @@ from collections import namedtuple, Counter, OrderedDict from test import mapping_tests import pickle, cPickle, copy from random import randrange, shuffle -import operator import keyword import re from collections import Hashable, Iterable, Iterator @@ -848,7 +847,7 @@ class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol): d = self._empty_mapping() self.assertRaises(KeyError, d.popitem) -import doctest, collections +import collections def test_main(verbose=None): NamedTupleDocs = doctest.DocTestSuite(module=collections) diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py index 27b6c3d..4e482d2 100644 --- a/Lib/test/test_commands.py +++ b/Lib/test/test_commands.py @@ -12,8 +12,7 @@ warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated", from test.test_support import run_unittest, reap_children, import_module # Silence Py3k warning -import_module('commands', deprecated=True) -from commands import * +commands = import_module('commands', deprecated=True) # The module says: # "NB This only works (and is only relevant) for UNIX." @@ -28,8 +27,8 @@ if os.name != 'posix': class CommandTests(unittest.TestCase): def test_getoutput(self): - self.assertEquals(getoutput('echo xyzzy'), 'xyzzy') - self.assertEquals(getstatusoutput('echo xyzzy'), (0, 'xyzzy')) + self.assertEquals(commands.getoutput('echo xyzzy'), 'xyzzy') + self.assertEquals(commands.getstatusoutput('echo xyzzy'), (0, 'xyzzy')) # we use mkdtemp in the next line to create an empty directory # under our exclusive control; from that, we can invent a pathname @@ -39,7 +38,7 @@ class CommandTests(unittest.TestCase): dir = tempfile.mkdtemp() name = os.path.join(dir, "foo") - status, output = getstatusoutput('cat ' + name) + status, output = commands.getstatusoutput('cat ' + name) self.assertNotEquals(status, 0) finally: if dir is not None: @@ -60,7 +59,7 @@ class CommandTests(unittest.TestCase): /\. # and end with the name of the file. ''' - self.assertTrue(re.match(pat, getstatus("/."), re.VERBOSE)) + self.assertTrue(re.match(pat, commands.getstatus("/."), re.VERBOSE)) def test_main(): diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py index 219d85f..19890b5 100644 --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -4,9 +4,7 @@ import os import py_compile import shutil import struct -import sys import tempfile -import time from test import test_support import unittest diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py index 80ba3e8..6350717 100644 --- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -1,9 +1,7 @@ """Unit tests for contextlib.py, and other context managers.""" -import sys import os -import decimal import tempfile import unittest import threading @@ -147,7 +145,6 @@ class NestedTestCase(unittest.TestCase): self.fail("Didn't raise ZeroDivisionError") def test_nested_right_exception(self): - state = [] @contextmanager def a(): yield 1 diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_cookielib.py index d3f77dd..b75511c 100644 --- a/Lib/test/test_cookielib.py +++ b/Lib/test/test_cookielib.py @@ -1722,7 +1722,6 @@ class LWPCookieTests(TestCase): def test_main(verbose=None): - from test import test_sets test_support.run_unittest( DateTimeTests, HeaderTests, diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py index 685fd6e..e3503c4 100644 --- a/Lib/test/test_copy.py +++ b/Lib/test/test_copy.py @@ -3,7 +3,6 @@ import copy import copy_reg import weakref -import operator import unittest from test import test_support diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index f57f38d..aa1ba9b 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -24,7 +24,6 @@ you're working through IDLE, you can import this test module and call test_main( with the corresponding argument. """ -import glob import math import os, sys import pickle, copy diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py index 27b1ad8..7de016f 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -6,7 +6,6 @@ import weakref import copy import cPickle as pickle import random -import os BIG = 100000 diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index b0366bd..8ec03087 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -261,7 +261,6 @@ class OperatorsTest(unittest.TestCase): pass else: self.fail("NotImplemented should have caused TypeError") - import sys try: C(sys.maxint+1) except OverflowError: @@ -654,7 +653,6 @@ class ClassPropertiesAndMethods(unittest.TestCase): def test_module_subclasses(self): # Testing Python subclass of module... log = [] - import types, sys MT = type(sys) class MM(MT): def __init__(self, name): @@ -1131,7 +1129,6 @@ order (MRO) for bases """ # Test cyclical leaks [SF bug 519621] class F(object): __slots__ = ['a', 'b'] - log = [] s = F() s.a = [Counted(), s] self.assertEqual(Counted.counter, 1) @@ -1140,7 +1137,7 @@ order (MRO) for bases """ self.assertEqual(Counted.counter, 0) # Test lookup leaks [SF bug 572567] - import sys,gc + import gc if hasattr(gc, 'get_objects'): class G(object): def __cmp__(self, other): @@ -1945,7 +1942,6 @@ order (MRO) for bases """ return 'EPS' return self # sys.stdout needs to be the original to trigger the recursion bug - import sys test_stdout = sys.stdout sys.stdout = test_support.get_original_stdout() try: @@ -2309,7 +2305,6 @@ order (MRO) for bases """ self.assertIn('im_self', dir(a.Amethod)) # Try a module subclass. - import sys class M(type(sys)): pass minstance = M("m") @@ -3506,7 +3501,6 @@ order (MRO) for bases """ self.fail("d.foo should be undefined now") # Test a nasty bug in recurse_down_subclasses() - import gc class A(object): pass class B(A): @@ -4327,7 +4321,6 @@ order (MRO) for bases """ def test_file_fault(self): # Testing sys.stdout is changed in getattr... - import sys test_stdout = sys.stdout class StdoutGuard: def __getattr__(self, attr): @@ -4416,8 +4409,6 @@ order (MRO) for bases """ def test_not_implemented(self): # Testing NotImplemented... # all binary methods should be able to return a NotImplemented - import sys - import types import operator def specialmethod(self, other): diff --git a/Lib/test/test_dircache.py b/Lib/test/test_dircache.py index 56799da..8a80720 100644 --- a/Lib/test/test_dircache.py +++ b/Lib/test/test_dircache.py @@ -4,7 +4,7 @@ """ import unittest -from test.test_support import run_unittest, TESTFN, import_module +from test.test_support import run_unittest, import_module dircache = import_module('dircache', deprecated=True) import os, time, sys, tempfile diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py index c7b7775..dae4109 100644 --- a/Lib/test/test_docxmlrpc.py +++ b/Lib/test/test_docxmlrpc.py @@ -5,7 +5,6 @@ import threading import time import socket import unittest -import xmlrpclib PORT = None diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py index b113547..b50db23 100644 --- a/Lib/test/test_epoll.py +++ b/Lib/test/test_epoll.py @@ -21,12 +21,10 @@ """ Tests for epoll wrapper. """ -import os import socket import errno import time import select -import tempfile import unittest from test import test_support diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index a91897e..9b6b435 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -12,7 +12,7 @@ from weakref import proxy import io import _pyio as pyio -from test.test_support import TESTFN, findfile, run_unittest +from test.test_support import TESTFN, run_unittest from UserList import UserList class AutoFileTests(unittest.TestCase): diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py index 5c2de37..d812927 100644 --- a/Lib/test/test_file2k.py +++ b/Lib/test/test_file2k.py @@ -8,7 +8,7 @@ from array import array from weakref import proxy from test import test_support -from test.test_support import TESTFN, findfile, run_unittest +from test.test_support import TESTFN, run_unittest from UserList import UserList class AutoFileTests(unittest.TestCase): diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py index f76ba0b..4739ede 100644 --- a/Lib/test/test_filecmp.py +++ b/Lib/test/test_filecmp.py @@ -1,5 +1,5 @@ -import os, filecmp, shutil, tempfile, shutil +import os, filecmp, shutil, tempfile import unittest from test import test_support diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index cdc3123..5589d05 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -10,8 +10,7 @@ from array import array from weakref import proxy from functools import wraps -from test.test_support import (TESTFN, findfile, check_warnings, run_unittest, - make_bad_fd) +from test.test_support import TESTFN, check_warnings, run_unittest, make_bad_fd from test.test_support import py3k_bytes as bytes from _io import FileIO as _FileIO diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index ac155c9..b043c4d 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -523,7 +523,6 @@ class IEEEFormatTestCase(unittest.TestCase): if float.__getformat__("double").startswith("IEEE"): def test_negative_zero(self): - import math def pos_pos(): return 0.0, math.atan2(0.0, -1) def pos_neg(): @@ -537,7 +536,6 @@ class IEEEFormatTestCase(unittest.TestCase): if float.__getformat__("double").startswith("IEEE"): def test_underflow_sign(self): - import math # check that -1e-1000 gives -0.0, not 0.0 self.assertEquals(math.atan2(-1e-1000, -1), math.atan2(-0.0, -1)) self.assertEquals(math.atan2(float('-1e-1000'), -1), diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py index 22e6f31..0640071 100644 --- a/Lib/test/test_fork1.py +++ b/Lib/test/test_fork1.py @@ -1,7 +1,6 @@ """This test checks for correct fork() behavior. """ -import errno import imp import os import signal diff --git a/Lib/test/test_frozen.py b/Lib/test/test_frozen.py index 1654be0..5f72a92 100644 --- a/Lib/test/test_frozen.py +++ b/Lib/test/test_frozen.py @@ -2,7 +2,7 @@ from test.test_support import captured_stdout, run_unittest import unittest -import sys, os +import sys class FrozenTests(unittest.TestCase): def test_frozen(self): diff --git a/Lib/test/test_future_builtins.py b/Lib/test/test_future_builtins.py index 0e16caf..96c3788 100644 --- a/Lib/test/test_future_builtins.py +++ b/Lib/test/test_future_builtins.py @@ -2,7 +2,6 @@ import test.test_support, unittest # we're testing the behavior of these future builtins: from future_builtins import hex, oct, map, zip, filter -from test import test_support class BuiltinTest(unittest.TestCase): def test_hex(self): diff --git a/Lib/test/test_gdbm.py b/Lib/test/test_gdbm.py index ee2a659..f4bbc38 100755 --- a/Lib/test/test_gdbm.py +++ b/Lib/test/test_gdbm.py @@ -1,7 +1,6 @@ import unittest import os -from test.test_support import (verbose, TESTFN, run_unittest, unlink, - import_module) +from test.test_support import TESTFN, run_unittest, unlink, import_module gdbm = import_module('gdbm') diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py index 4729301..6b18d9f 100644 --- a/Lib/test/test_getopt.py +++ b/Lib/test/test_getopt.py @@ -5,7 +5,6 @@ from test.test_support import verbose, run_doctest, run_unittest, EnvironmentVar import unittest import getopt -import os sentinel = object() diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index b5fee51..6ef5557 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -8,7 +8,6 @@ import array import hashlib -import StringIO import itertools import sys try: diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py index e377384..fac6845 100644 --- a/Lib/test/test_heapq.py +++ b/Lib/test/test_heapq.py @@ -367,8 +367,6 @@ class TestErrorHandling(unittest.TestCase): def test_main(verbose=None): - from types import BuiltinFunctionType - test_classes = [TestHeapPython, TestHeapC, TestErrorHandling] test_support.run_unittest(*test_classes) diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index bfda0de..81b2591 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -7,10 +7,7 @@ threading = support.import_module('threading') from contextlib import contextmanager import imaplib import os.path -import select -import socket import SocketServer -import sys import time from test_support import reap_threads, verbose diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index be469cb..451d309 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -4,7 +4,7 @@ import unittest import inspect import datetime -from test.test_support import TESTFN, run_unittest +from test.test_support import run_unittest from test import inspect_fodder as mod from test import inspect_fodder2 as mod2 diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 1c12252..0404c09 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -31,9 +31,8 @@ import random import unittest import warnings import weakref -import gc import abc -from itertools import chain, cycle, count +from itertools import cycle, count from collections import deque from test import test_support as support diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 0ef66a0..ae06341 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -42,7 +42,6 @@ from test.test_support import captured_stdout, run_with_locale, run_unittest,\ find_unused_port import textwrap import threading -import time import unittest import warnings import weakref diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 5c20dfe..e7bedeb 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -583,8 +583,6 @@ class LongTest(unittest.TestCase): # ----------------------------------- tests of auto int->long conversion def test_auto_overflow(self): - import math, sys - special = [0, 1, 2, 3, sys.maxint-1, sys.maxint, sys.maxint+1] sqrt = int(math.sqrt(sys.maxint)) special.extend([sqrt-1, sqrt, sqrt+1]) @@ -704,8 +702,6 @@ class LongTest(unittest.TestCase): self.assertEqual(long(float(x)), y) def test_float_overflow(self): - import math - for x in -2.0, -1.0, 0.0, 1.0, 2.0: self.assertEqual(float(long(x)), x) @@ -735,8 +731,6 @@ class LongTest(unittest.TestCase): "float(shuge) should not equal int(shuge)") def test_logs(self): - import math - LOG10E = math.log10(math.e) for exp in range(10) + [100, 1000, 10000]: @@ -756,7 +750,6 @@ class LongTest(unittest.TestCase): def test_mixed_compares(self): eq = self.assertEqual - import math # We're mostly concerned with that mixing floats and longs does the # right stuff, even when longs are too large to fit in a float. diff --git a/Lib/test/test_macos.py b/Lib/test/test_macos.py index ce5f858..465d304 100644 --- a/Lib/test/test_macos.py +++ b/Lib/test/test_macos.py @@ -4,8 +4,6 @@ import os import subprocess MacOS = test_support.import_module('MacOS') -#The following should exist if MacOS exists. -import Carbon.File TESTFN2 = test_support.TESTFN + '2' diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index aa31625..13fa826 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -11,7 +11,6 @@ from test import test_support as support import io import _pyio as pyio -import sys import pickle class MemorySeekTestMixin: diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py index c74e329..517a682 100644 --- a/Lib/test/test_multibytecodec.py +++ b/Lib/test/test_multibytecodec.py @@ -5,7 +5,6 @@ # from test import test_support -from test import test_multibytecodec_support from test.test_support import TESTFN import unittest, StringIO, codecs, sys, os import _multibytecodec diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 02dc38c..9e9b6ed 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -1,6 +1,6 @@ import ntpath import os -from test.test_support import verbose, TestFailed +from test.test_support import TestFailed import test.test_support as test_support import unittest diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py index d3ed61f..7733813 100644 --- a/Lib/test/test_optparse.py +++ b/Lib/test/test_optparse.py @@ -19,9 +19,9 @@ from StringIO import StringIO from test import test_support -from optparse import make_option, Option, IndentedHelpFormatter, \ - TitledHelpFormatter, OptionParser, OptionContainer, OptionGroup, \ - SUPPRESS_HELP, SUPPRESS_USAGE, OptionError, OptionConflictError, \ +from optparse import make_option, Option, \ + TitledHelpFormatter, OptionParser, OptionGroup, \ + SUPPRESS_USAGE, OptionError, OptionConflictError, \ BadOptionError, OptionValueError, Values from optparse import _match_abbrev from optparse import _parse_num @@ -1236,7 +1236,6 @@ class TestCallbackVarArgs(BaseTest): def variable_args(self, option, opt, value, parser): self.assertTrue(value is None) - done = 0 value = [] rargs = parser.rargs while rargs: diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 9900fa0..f8bb16b 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -134,7 +134,6 @@ class TemporaryFileTests(unittest.TestCase): self.assertTrue(s == "foobar") def test_tmpnam(self): - import sys if not hasattr(os, "tmpnam"): return warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, @@ -185,8 +184,6 @@ class StatAttributeTests(unittest.TestCase): self.assertEquals(result[stat.ST_SIZE], 3) self.assertEquals(result.st_size, 3) - import sys - # Make sure all the attributes are there members = dir(result) for name in dir(stat): diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 9fb949f..07a4c32 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -1,5 +1,4 @@ import parser -import os import unittest import sys from test import test_support diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 6017edc..ce64d17 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -2,10 +2,7 @@ # specified test modules (RFE #5142). import imp -import os import sys -import doctest -import tempfile from test import test_support # This little helper class is essential for testing pdb under doctest. diff --git a/Lib/test/test_print.py b/Lib/test/test_print.py index f53d9c5..757f90f 100644 --- a/Lib/test/test_print.py +++ b/Lib/test/test_print.py @@ -8,7 +8,6 @@ from __future__ import print_function import unittest from test import test_support -import sys from StringIO import StringIO NotDefined = object() diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py index fe88d12..e40beaf 100755 --- a/Lib/test/test_profile.py +++ b/Lib/test/test_profile.py @@ -1,6 +1,5 @@ """Test suite for the profile module.""" -import os import sys import pstats import unittest diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 0628a57..68a1451 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -4,7 +4,6 @@ import StringIO, sys import unittest -import pyexpat from xml.parsers import expat from test.test_support import sortdict, run_unittest diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py index 715466f..1636280 100644 --- a/Lib/test/test_queue.py +++ b/Lib/test/test_queue.py @@ -1,7 +1,6 @@ # Some simple queue module tests, plus some failure conditions # to ensure the Queue locks remain stable. import Queue -import sys import threading import time import unittest diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index ce07efc..b4998b9 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -5,7 +5,7 @@ import random import time import pickle import warnings -from math import log, exp, sqrt, pi, fsum, sin +from math import log, exp, pi, fsum, sin from functools import reduce from test import test_support diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 8136002..ba2f521 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1,7 +1,7 @@ from test.test_support import verbose, run_unittest import re from re import Scanner -import sys, os, traceback +import sys, traceback from weakref import proxy # Misc tests from Tim Peters' re.doc @@ -715,7 +715,7 @@ class ReTests(unittest.TestCase): self.assertRaises(OverflowError, _sre.compile, "abc", 0, [long_overflow]) def run_re_tests(): - from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR + from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR if verbose: print 'Running re_tests test suite' else: diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index debb2be..32f2803 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -5,7 +5,6 @@ import weakref import operator import copy import pickle -import os from random import randrange, shuffle import sys import collections @@ -1694,7 +1693,6 @@ class TestGraphs(unittest.TestCase): #============================================================================== def test_main(verbose=None): - from test import test_sets test_classes = ( TestSet, TestSetSubclass, diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 7a655b3..a938831 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -3,7 +3,6 @@ Test suite for SocketServer.py. """ import contextlib -import errno import imp import os import select @@ -11,13 +10,11 @@ import signal import socket import tempfile import threading -import time import unittest import SocketServer import test.test_support from test.test_support import reap_children, reap_threads, verbose -from test.test_support import TESTFN as TEST_FILE test.test_support.requires("network") diff --git a/Lib/test/test_sqlite.py b/Lib/test/test_sqlite.py index 167408c..db27331 100644 --- a/Lib/test/test_sqlite.py +++ b/Lib/test/test_sqlite.py @@ -1,4 +1,3 @@ -import unittest from test.test_support import run_unittest, import_module # Skip test if _sqlite3 module was not built. diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index b16c3d6..d452317 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -6,13 +6,10 @@ from test import test_support import asyncore import socket import select -import errno -import subprocess import time import os import pprint import urllib, urlparse -import shutil import traceback from BaseHTTPServer import HTTPServer diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py index cc36ed7..41e16f5 100755 --- a/Lib/test/test_strftime.py +++ b/Lib/test/test_strftime.py @@ -4,7 +4,6 @@ Unittest for time.strftime import calendar import sys -import os import re from test import test_support import time diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 556a576..fc48c11 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -6,7 +6,7 @@ warnings.filterwarnings("ignore", "struct integer overflow masking is deprecated DeprecationWarning) from functools import wraps -from test.test_support import TestFailed, verbose, run_unittest +from test.test_support import run_unittest import sys ISBIGENDIAN = sys.byteorder == "big" diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py index c196cc5..d1b33a1 100644 --- a/Lib/test/test_structmembers.py +++ b/Lib/test/test_structmembers.py @@ -5,7 +5,7 @@ from _testcapi import test_structmembersType, \ LONG_MAX, LONG_MIN, ULONG_MAX, \ LLONG_MAX, LLONG_MIN, ULLONG_MAX -import warnings, exceptions, unittest, sys +import unittest from test import test_support ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8, diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index f7e828b..15b88ce 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1,6 +1,6 @@ # -*- coding: iso-8859-1 -*- import unittest, test.test_support -import sys, cStringIO, os +import sys, os, cStringIO import struct import operator @@ -415,7 +415,7 @@ class SysModuleTest(unittest.TestCase): sys._clear_type_cache() def test_ioencoding(self): - import subprocess,os + import subprocess env = dict(os.environ) # Test character: cent sign, encoded as 0x4A (ASCII J) in CP424, diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index f00e041..c8bae73 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -6,7 +6,6 @@ executing have not been removed. """ import unittest import sys -import test import os import shutil from copy import copy, deepcopy @@ -80,7 +79,7 @@ class TestSysConfig(unittest.TestCase): return self._uname def _cleanup_testfn(self): - path = test.test_support.TESTFN + path = TESTFN if os.path.isfile(path): os.remove(path) elif os.path.isdir(path): diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 9e9b83c..938e48b 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -3,7 +3,6 @@ import sys import os import shutil -import tempfile import StringIO from hashlib import md5 import errno diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index 2b73f54..e534d62 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -3,7 +3,6 @@ import tempfile import os import sys import re -import errno import warnings import unittest diff --git a/Lib/test/test_tk.py b/Lib/test/test_tk.py index eb9671f..49ca53f 100644 --- a/Lib/test/test_tk.py +++ b/Lib/test/test_tk.py @@ -1,5 +1,4 @@ import os -import sys import unittest from test import test_support diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py index 5599921..b8e97e7 100644 --- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -529,7 +529,7 @@ Evil tabs from test import test_support -from tokenize import (tokenize, untokenize, generate_tokens, NUMBER, NAME, OP, +from tokenize import (untokenize, generate_tokens, NUMBER, NAME, OP, STRING, ENDMARKER, tok_name) from StringIO import StringIO import os diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index f7e7c8d..c79961e 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -67,7 +67,7 @@ class TracebackCases(unittest.TestCase): self.assertTrue(err[1].find("2") == err[2].find("^")) def test_bug737473(self): - import sys, os, tempfile, time + import os, tempfile, time savedpath = sys.path[:] testdir = tempfile.mkdtemp() diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk_guionly.py index 421f014..f163364 100644 --- a/Lib/test/test_ttk_guionly.py +++ b/Lib/test/test_ttk_guionly.py @@ -1,5 +1,4 @@ import os -import sys import unittest from test import test_support diff --git a/Lib/test/test_ttk_textonly.py b/Lib/test/test_ttk_textonly.py index e0cb2f5..ed92043d 100644 --- a/Lib/test/test_ttk_textonly.py +++ b/Lib/test/test_ttk_textonly.py @@ -1,5 +1,4 @@ import os -import sys from test import test_support # Skip this test if _tkinter does not exist. diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 4ee345a..498f73a 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -20,7 +20,6 @@ class TypesTests(unittest.TestCase): if not {'x': 1}: self.fail('{\'x\': 1} is false instead of true') def f(): pass class C: pass - import sys x = C() if not f: self.fail('f is false instead of true') if not C: self.fail('C is false instead of true') diff --git a/Lib/test/test_undocumented_details.py b/Lib/test/test_undocumented_details.py index ca66c19..0a92197 100644 --- a/Lib/test/test_undocumented_details.py +++ b/Lib/test/test_undocumented_details.py @@ -1,6 +1,5 @@ -from test.test_support import run_unittest, have_unicode +from test.test_support import run_unittest import unittest -import sys class TestImplementationComparisons(unittest.TestCase): diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py index 829a467..5415145 100644 --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -6,9 +6,7 @@ from test.test_urllib2 import sanepathname2url import socket import urllib2 -import sys import os -import mimetools def _retry_thrice(func, exc, *args, **kwargs): @@ -73,7 +71,7 @@ class AuthTests(unittest.TestCase): class CloseSocketTest(unittest.TestCase): def test_close(self): - import socket, httplib, gc + import httplib # calling .close() on urllib2's response objects should close the # underlying socket @@ -154,7 +152,6 @@ class OtherNetworkTests(unittest.TestCase): ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) def _test_urls(self, urls, handlers, retry=True): - import socket import time import logging debug = logging.getLogger("test_urllib2").debug diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 2e24ed1..2ccb77a 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -2,7 +2,6 @@ # all included components work as they should. For a more extensive # test suite, see the selftest script in the ElementTree distribution. -import doctest import sys from test import test_support diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py index 68e6d2c..b3c0200 100644 --- a/Lib/test/test_xml_etree_c.py +++ b/Lib/test/test_xml_etree_c.py @@ -1,6 +1,5 @@ # xml.etree test for cElementTree -import doctest import sys from test import test_support diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py index ac21958..7e2c283 100644 --- a/Lib/test/test_zipimport_support.py +++ b/Lib/test/test_zipimport_support.py @@ -2,7 +2,6 @@ # for working with modules located inside zipfiles # The tests are centralised in this fashion to make it easy to drop them # if a platform doesn't support zipimport -import unittest import test.test_support import os import os.path @@ -15,8 +14,7 @@ import inspect import linecache import pdb from test.script_helper import (spawn_python, kill_python, run_python, - temp_dir, make_script, compile_script, - make_pkg, make_zip_script, make_zip_pkg) + temp_dir, make_script, make_zip_script) verbose = test.test_support.verbose |