diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-05-20 21:35:26 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-05-20 21:35:26 +0000 |
commit | ee8712cda46338d223509cc5751fd36509ad3860 (patch) | |
tree | bb9d363b4276566415457980472001c7e3ec2bed /Lib/test | |
parent | 6a654814ea3f3a918935762ffdcd33ae98e00278 (diff) | |
download | cpython-git-ee8712cda46338d223509cc5751fd36509ad3860.tar.gz |
#2621 rename test.test_support to test.support
Diffstat (limited to 'Lib/test')
334 files changed, 1274 insertions, 1275 deletions
diff --git a/Lib/test/double_const.py b/Lib/test/double_const.py index 16c33a19c9..67852aaf98 100644 --- a/Lib/test/double_const.py +++ b/Lib/test/double_const.py @@ -1,4 +1,4 @@ -from test.test_support import TestFailed +from test.support import TestFailed # A test for SF bug 422177: manifest float constants varied way too much in # precision depending on whether Python was loading a module for the first diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index 4ffa6684e6..6250908ba5 100644 --- a/Lib/test/list_tests.py +++ b/Lib/test/list_tests.py @@ -5,7 +5,7 @@ Tests common to list and UserList.UserList import sys import os -from test import test_support, seq_tests +from test import support, seq_tests def CmpToKey(mycmp): 'Convert a cmp= function into a key= function' @@ -66,14 +66,14 @@ class CommonTest(seq_tests.CommonTest): d.append(d) d.append(400) try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") fo.write(str(d)) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(d)) finally: fo.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_set_subscript(self): a = self.type2test(range(20)) diff --git a/Lib/test/outstanding_bugs.py b/Lib/test/outstanding_bugs.py index 3f672fb9d1..9e4784ce16 100644 --- a/Lib/test/outstanding_bugs.py +++ b/Lib/test/outstanding_bugs.py @@ -7,7 +7,7 @@ # import unittest -from test import test_support +from test import support # # One test case for outstanding bugs at the moment: @@ -22,7 +22,7 @@ class TextIOWrapperTest(unittest.TestCase): self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ASCII") def tearDown(self): - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_issue1395_1(self): @@ -81,7 +81,7 @@ class TextIOWrapperTest(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( TextIOWrapperTest) if __name__ == "__main__": diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 666b9c269d..783d3612fc 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -3,7 +3,7 @@ import pickle import pickletools import copyreg -from test.test_support import TestFailed, TESTFN, run_with_locale +from test.support import TestFailed, TESTFN, run_with_locale from pickle import bytes_types diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index f87b8a8f86..41772c662d 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -171,7 +171,7 @@ if sys.platform == 'darwin': newsoft = min(hard, max(soft, 1024*2048)) resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard)) -from test import test_support +from test import support RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', 'decimal', 'compiler', 'subprocess', 'urlfetch') @@ -209,7 +209,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, values that would normally be set by flags on the command line. """ - test_support.record_original_stdout(sys.stdout) + support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsSrf:lu:t:TD:NLR:wM:n', ['help', 'verbose', 'quiet', 'exclude', @@ -284,7 +284,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, # stringobject.c filling slowly with random data warm_char_cache() elif o in ('-M', '--memlimit'): - test_support.set_memlimit(a) + support.set_memlimit(a) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: @@ -390,8 +390,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix], trace=False, count=True) test_times = [] - test_support.verbose = verbose # Tell tests to be moderately quiet - test_support.use_resources = use_resources + support.verbose = verbose # Tell tests to be moderately quiet + support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: @@ -433,7 +433,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): - test_support.unload(module) + support.unload(module) # The lists won't be sorted if running with -r good.sort() @@ -479,7 +479,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, print("Re-running test %r in verbose mode" % test) sys.stdout.flush() try: - test_support.verbose = True + support.verbose = True ok = runtest(test, generate, True, quiet, test_times, testdir, huntrleaks, debug) except KeyboardInterrupt: @@ -526,7 +526,6 @@ STDTESTS = [ ] NOTTESTS = { - 'test_support', 'test_future1', 'test_future2', } @@ -572,7 +571,7 @@ def runtest(test, generate, verbose, quiet, test_times, def runtest_inner(test, generate, verbose, quiet, test_times, testdir=None, huntrleaks=False, debug=False): - test_support.unload(test) + support.unload(test) if not testdir: testdir = findtestdir() if verbose: @@ -606,19 +605,19 @@ def runtest_inner(test, generate, verbose, quiet, test_times, test_times.append((test_time, test)) finally: sys.stdout = save_stdout - except test_support.ResourceDenied as msg: + except support.ResourceDenied as msg: if not quiet: print(test, "skipped --", msg) sys.stdout.flush() return -2 - except (ImportError, test_support.TestSkipped) as msg: + except (ImportError, support.TestSkipped) as msg: if not quiet: print(test, "skipped --", msg) sys.stdout.flush() return -1 except KeyboardInterrupt: raise - except test_support.TestFailed as msg: + except support.TestFailed as msg: print("test", test, "failed --", msg) sys.stdout.flush() return 0 @@ -652,7 +651,7 @@ def cleanup_test_droppings(testname, verbose): # since if a test leaves a file open, it cannot be deleted by name (while # there's nothing we can do about that here either, we can display the # name of the offending test, which is a real help). - for name in (test_support.TESTFN, + for name in (support.TESTFN, "db_home", ): if not os.path.exists(name): @@ -1206,10 +1205,10 @@ class _ExpectedSkips: if __name__ == '__main__': # Remove regrtest.py's own directory from the module search path. This # prevents relative imports from working, and relative imports will screw - # up the testing framework. E.g. if both test.test_support and - # test_support are imported, they will not contain the same globals, and + # up the testing framework. E.g. if both test.support and + # support are imported, they will not contain the same globals, and # much of the testing framework relies on the globals in the - # test.test_support module. + # test.support module. mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) i = pathlen = len(sys.path) while i >= 0: diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index caafb31388..60308d7400 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -3,7 +3,7 @@ Common tests shared by test_str, test_unicode, test_userstring and test_string. """ import unittest, string, sys, struct -from test import test_support +from test import support from collections import UserList class Sequence: diff --git a/Lib/test/test_support.py b/Lib/test/support.py index c4084bb3c6..b8bc406011 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/support.py @@ -1,7 +1,7 @@ """Supporting definitions for the Python regression tests.""" -if __name__ != 'test.test_support': - raise ImportError('test_support must be imported from the test package') +if __name__ != 'test.support': + raise ImportError('support must be imported from the test package') import contextlib import errno @@ -700,7 +700,7 @@ def run_doctest(module, verbosity=None): """Run doctest on the given module. Return (#failures, #tests). If optional argument verbosity is not specified (or is None), pass - test_support's belief about verbosity on to doctest. Else doctest's + support's belief about verbosity on to doctest. Else doctest's usual behavior is used (it searches sys.argv for -v). """ diff --git a/Lib/test/test_SimpleHTTPServer.py b/Lib/test/test_SimpleHTTPServer.py index 9d3ad16be6..d285f274f1 100644 --- a/Lib/test/test_SimpleHTTPServer.py +++ b/Lib/test/test_SimpleHTTPServer.py @@ -5,7 +5,7 @@ We don't want to require the 'network' resource. import os, unittest from SimpleHTTPServer import SimpleHTTPRequestHandler -from test import test_support +from test import support class SocketlessRequestHandler (SimpleHTTPRequestHandler): @@ -35,7 +35,7 @@ class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(SimpleHTTPRequestHandlerTestCase) + support.run_unittest(SimpleHTTPRequestHandlerTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index 9d0487d8f5..c58aeadace 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import run_unittest, catch_warning +from test.support import run_unittest, catch_warning import sys import warnings diff --git a/Lib/test/test___future__.py b/Lib/test/test___future__.py index 9504155499..77006e1abc 100644 --- a/Lib/test/test___future__.py +++ b/Lib/test/test___future__.py @@ -1,6 +1,6 @@ #! /usr/bin/env python import unittest -from test import test_support +from test import support import __future__ GOOD_SERIALS = ("alpha", "beta", "candidate", "final") @@ -57,7 +57,7 @@ class FutureTest(unittest.TestCase): ".compiler_flag isn't int") def test_main(): - test_support.run_unittest(FutureTest) + support.run_unittest(FutureTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py index aed273d1e6..9dec027d21 100644 --- a/Lib/test/test__locale.py +++ b/Lib/test/test__locale.py @@ -1,4 +1,4 @@ -from test.test_support import verbose, TestSkipped, run_unittest +from test.support import verbose, TestSkipped, run_unittest from _locale import (setlocale, LC_ALL, LC_CTYPE, LC_NUMERIC, RADIXCHAR, THOUSEP, nl_langinfo, localeconv, Error) import unittest diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py index d631c3ebf5..a4cefc5328 100644 --- a/Lib/test/test_abc.py +++ b/Lib/test/test_abc.py @@ -4,7 +4,7 @@ """Unit tests for abc.py.""" import unittest -from test import test_support +from test import support import abc from inspect import isabstract @@ -170,7 +170,7 @@ class TestABC(unittest.TestCase): def test_main(): - test_support.run_unittest(TestABC) + support.run_unittest(TestABC) if __name__ == "__main__": diff --git a/Lib/test/test_abstract_numbers.py b/Lib/test/test_abstract_numbers.py index 244f87ab0f..e20f2d42c0 100644 --- a/Lib/test/test_abstract_numbers.py +++ b/Lib/test/test_abstract_numbers.py @@ -5,7 +5,7 @@ import operator import unittest from numbers import Complex, Real, Rational, Integral from numbers import Number -from test import test_support +from test import support class TestNumbers(unittest.TestCase): def test_int(self): @@ -40,7 +40,7 @@ class TestNumbers(unittest.TestCase): self.assertRaises(TypeError, int, c1) def test_main(): - test_support.run_unittest(TestNumbers) + support.run_unittest(TestNumbers) if __name__ == "__main__": diff --git a/Lib/test/test_anydbm.py b/Lib/test/test_anydbm.py index 9399d711cf..ace9dd207c 100644 --- a/Lib/test/test_anydbm.py +++ b/Lib/test/test_anydbm.py @@ -7,9 +7,9 @@ import os import unittest import anydbm import glob -from test import test_support +from test import support -_fname = test_support.TESTFN +_fname = support.TESTFN _all_modules = [] @@ -121,7 +121,7 @@ class AnyDBMTestCase(unittest.TestCase): def test_main(): try: for module in dbm_iterator(): - test_support.run_unittest(AnyDBMTestCase) + support.run_unittest(AnyDBMTestCase) finally: delete_files() diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 70fac6668d..66ce2ad23e 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -4,7 +4,7 @@ """ import unittest -from test import test_support +from test import support from weakref import proxy import array, io, math from pickle import loads, dumps @@ -162,13 +162,13 @@ class BaseTest(unittest.TestCase): def test_tofromfile(self): a = array.array(self.typecode, 2*self.example) self.assertRaises(TypeError, a.tofile) - test_support.unlink(test_support.TESTFN) - f = open(test_support.TESTFN, 'wb') + support.unlink(support.TESTFN) + f = open(support.TESTFN, 'wb') try: a.tofile(f) f.close() b = array.array(self.typecode) - f = open(test_support.TESTFN, 'rb') + f = open(support.TESTFN, 'rb') self.assertRaises(TypeError, b.fromfile) b.fromfile(f, len(self.example)) self.assertEqual(b, array.array(self.typecode, self.example)) @@ -180,7 +180,7 @@ class BaseTest(unittest.TestCase): finally: if not f.closed: f.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_tofromlist(self): a = array.array(self.typecode, 2*self.example) @@ -967,14 +967,14 @@ tests.append(DoubleTest) def test_main(verbose=None): import sys - test_support.run_unittest(*tests) + support.run_unittest(*tests) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*tests) + support.run_unittest(*tests) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index f4fbc94f5a..4c74cf7dbf 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -1,5 +1,5 @@ import sys, unittest -from test import test_support +from test import support import _ast def to_tuple(t): @@ -176,7 +176,7 @@ class AST_Tests(unittest.TestCase): self.assertEquals(to_tuple(ast2), to_tuple(ast)) def test_main(): - test_support.run_unittest(AST_Tests) + support.run_unittest(AST_Tests) def main(): if __name__ != '__main__': diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py index d24e8cc326..4d49f581de 100644 --- a/Lib/test/test_asynchat.py +++ b/Lib/test/test_asynchat.py @@ -4,9 +4,9 @@ import thread # If this fails, we can't test this module import asyncore, asynchat, socket, threading, time import unittest import sys -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST SERVER_QUIT = b'QUIT\n' class echo_server(threading.Thread): @@ -18,7 +18,7 @@ class echo_server(threading.Thread): threading.Thread.__init__(self) self.event = event self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) def run(self): self.sock.listen(1) @@ -248,7 +248,7 @@ class TestFifo(unittest.TestCase): def test_main(verbose=None): - test_support.run_unittest(TestAsynchat, TestAsynchat_WithPoll, + support.run_unittest(TestAsynchat, TestAsynchat_WithPoll, TestHelperFunctions, TestFifo) if __name__ == "__main__": diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index 09401bd839..eb52687866 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -7,12 +7,12 @@ import threading import sys import time -from test import test_support -from test.test_support import TESTFN, run_unittest, unlink +from test import support +from test.support import TESTFN, run_unittest, unlink from io import BytesIO from io import StringIO -HOST = test_support.HOST +HOST = support.HOST class dummysocket: def __init__(self): @@ -334,7 +334,7 @@ class DispatcherWithSendTests(unittest.TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(3) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) cap = BytesIO() args = (self.evt, cap, self.sock) diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py index 76a50362ca..6856042edc 100644 --- a/Lib/test/test_atexit.py +++ b/Lib/test/test_atexit.py @@ -2,7 +2,7 @@ import sys import unittest import io import atexit -from test import test_support +from test import support ### helpers def h1(): @@ -109,7 +109,7 @@ class TestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(TestCase) + support.run_unittest(TestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py index ab8be02d8b..ae796ba574 100644 --- a/Lib/test/test_audioop.py +++ b/Lib/test/test_audioop.py @@ -1,6 +1,6 @@ # Test audioop. import audioop -from test.test_support import verbose +from test.support import verbose def gendata1(): return b'\0\1\2' diff --git a/Lib/test/test_augassign.py b/Lib/test/test_augassign.py index 0309d6e0b1..e03b4d4e5c 100644 --- a/Lib/test/test_augassign.py +++ b/Lib/test/test_augassign.py @@ -1,6 +1,6 @@ # Augmented assignment test. -from test.test_support import run_unittest +from test.support import run_unittest import unittest diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py index c50652cac5..e899016f78 100644 --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import base64 import binascii @@ -209,7 +209,7 @@ class BaseXYTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_bigaddrspace.py b/Lib/test/test_bigaddrspace.py index 8c215fe09a..3aedc4cf35 100644 --- a/Lib/test/test_bigaddrspace.py +++ b/Lib/test/test_bigaddrspace.py @@ -1,5 +1,5 @@ -from test import test_support -from test.test_support import bigaddrspacetest, MAX_Py_ssize_t +from test import support +from test.support import bigaddrspacetest, MAX_Py_ssize_t import unittest import operator @@ -38,9 +38,9 @@ class StrTest(unittest.TestCase): def test_main(): - test_support.run_unittest(StrTest) + support.run_unittest(StrTest) if __name__ == '__main__': if len(sys.argv) > 1: - test_support.set_memlimit(sys.argv[1]) + support.set_memlimit(sys.argv[1]) test_main() diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py index 27e1ecf5f2..30e1bdb18c 100644 --- a/Lib/test/test_bigmem.py +++ b/Lib/test/test_bigmem.py @@ -1,5 +1,5 @@ -from test import test_support -from test.test_support import bigmemtest, _1G, _2G +from test import support +from test.support import bigmemtest, _1G, _2G import unittest import operator @@ -957,9 +957,9 @@ class ListTest(unittest.TestCase): self.assertEquals(l[-10:], [5] * 10) def test_main(): - test_support.run_unittest(StrTest, TupleTest, ListTest) + support.run_unittest(StrTest, TupleTest, ListTest) if __name__ == '__main__': if len(sys.argv) > 1: - test_support.set_memlimit(sys.argv[1]) + support.set_memlimit(sys.argv[1]) test_main() diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index fb9a666378..76a76b247f 100755 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -1,6 +1,6 @@ """Test the binascii C module.""" -from test import test_support +from test import support import unittest import binascii @@ -169,7 +169,7 @@ class BinASCIITest(unittest.TestCase): binascii.crc_hqx('', 0) def test_main(): - test_support.run_unittest(BinASCIITest) + support.run_unittest(BinASCIITest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_binhex.py b/Lib/test/test_binhex.py index 61c24c9d11..06fd98aa64 100755 --- a/Lib/test/test_binhex.py +++ b/Lib/test/test_binhex.py @@ -7,18 +7,18 @@ import binhex import os import unittest -from test import test_support +from test import support class BinHexTestCase(unittest.TestCase): def setUp(self): - self.fname1 = test_support.TESTFN + "1" - self.fname2 = test_support.TESTFN + "2" + self.fname1 = support.TESTFN + "1" + self.fname2 = support.TESTFN + "2" def tearDown(self): - test_support.unlink(self.fname1) - test_support.unlink(self.fname2) + support.unlink(self.fname1) + support.unlink(self.fname2) DATA = b'Jack is my hero' @@ -39,7 +39,7 @@ class BinHexTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(BinHexTestCase) + support.run_unittest(BinHexTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py index f0433fbd7e..b260b1bf61 100644 --- a/Lib/test/test_binop.py +++ b/Lib/test/test_binop.py @@ -1,7 +1,7 @@ """Tests for binary operators on subtypes of built-in types.""" import unittest -from test import test_support +from test import support def gcd(a, b): """Greatest common divisor using Euclid's algorithm.""" @@ -317,7 +317,7 @@ self.assertEqual(eval('1/2'), 0.5) """ def test_main(): - test_support.run_unittest(RatTestCase) + support.run_unittest(RatTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py index 11495bad8a..af9f1f7c64 100644 --- a/Lib/test/test_bisect.py +++ b/Lib/test/test_bisect.py @@ -1,6 +1,6 @@ import sys import unittest -from test import test_support +from test import support from collections import UserList # We do a bit of trickery here to be able to test both the C implementation @@ -286,15 +286,15 @@ def test_main(verbose=None): TestInsortPython, TestInsortC, TestErrorHandlingPython, TestErrorHandlingC] - test_support.run_unittest(*test_classes) - test_support.run_doctest(test_bisect, verbose) + support.run_unittest(*test_classes) + support.run_doctest(test_bisect, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_bool.py b/Lib/test/test_bool.py index bbaea85c63..591b0eb396 100644 --- a/Lib/test/test_bool.py +++ b/Lib/test/test_bool.py @@ -1,7 +1,7 @@ # Test properties of bool promised by PEP 285 import unittest -from test import test_support +from test import support import os @@ -26,14 +26,14 @@ class BoolTest(unittest.TestCase): def test_print(self): try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") print(False, True, file=fo) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), 'False True\n') finally: fo.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_repr(self): self.assertEqual(repr(False), 'False') @@ -234,12 +234,12 @@ class BoolTest(unittest.TestCase): def test_fileclosed(self): try: - f = open(test_support.TESTFN, "w") + f = open(support.TESTFN, "w") self.assertIs(f.closed, False) f.close() self.assertIs(f.closed, True) finally: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_operator(self): import operator @@ -331,7 +331,7 @@ class BoolTest(unittest.TestCase): self.assertEqual(str(e_bool), str(e_len)) def test_main(): - test_support.run_unittest(BoolTest) + support.run_unittest(BoolTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py index dfee3dcb11..3eb291f3a9 100755 --- a/Lib/test/test_bsddb.py +++ b/Lib/test/test_bsddb.py @@ -7,7 +7,7 @@ import copy import bsddb import dbhash # Just so we know it's imported import unittest -from test import test_support +from test import support class TestBSDDB(unittest.TestCase): openflag = 'c' @@ -274,7 +274,7 @@ class TestBSDDB(unittest.TestCase): self.assertEqual(list(self.f), keys) class TestBTree(TestBSDDB): - fname = test_support.TESTFN + fname = support.TESTFN openmethod = [bsddb.btopen] class TestBTree_InMemory(TestBSDDB): @@ -287,7 +287,7 @@ class TestBTree_InMemory_Truncate(TestBSDDB): openmethod = [bsddb.btopen] class TestHashTable(TestBSDDB): - fname = test_support.TESTFN + fname = support.TESTFN openmethod = [bsddb.hashopen] class TestHashTable_InMemory(TestBSDDB): @@ -299,7 +299,7 @@ class TestHashTable_InMemory(TestBSDDB): ## # Solaris Intel - rmasse 1/97 def test_main(verbose=None): - test_support.run_unittest( + support.run_unittest( TestBTree, TestHashTable, TestBTree_InMemory, diff --git a/Lib/test/test_bsddb3.py b/Lib/test/test_bsddb3.py index 1f58c121c7..6a277d9798 100644 --- a/Lib/test/test_bsddb3.py +++ b/Lib/test/test_bsddb3.py @@ -7,7 +7,7 @@ import sys import tempfile import time import unittest -from test.test_support import requires, verbose, run_unittest, unlink, rmtree +from test.support import requires, verbose, run_unittest, unlink, rmtree # When running as a script instead of within the regrtest framework, skip the # requires test, since it's obvious we want to run them. diff --git a/Lib/test/test_bufio.py b/Lib/test/test_bufio.py index 804a401a25..e65951d77c 100644 --- a/Lib/test/test_bufio.py +++ b/Lib/test/test_bufio.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support # Simple test to ensure that optimizations in fileobject.c deliver # the expected results. For best testing, run this under a debug-build @@ -14,18 +14,18 @@ class BufferSizeTest(unittest.TestCase): # .readline()s deliver what we wrote. # Ensure we can open TESTFN for writing. - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) # Since C doesn't guarantee we can write/read arbitrary bytes in text # files, use binary mode. - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: # write once with \n and once without f.write(s) f.write(b"\n") f.write(s) f.close() - f = open(test_support.TESTFN, "rb") + f = open(support.TESTFN, "rb") line = f.readline() self.assertEqual(line, s + b"\n") line = f.readline() @@ -34,7 +34,7 @@ class BufferSizeTest(unittest.TestCase): self.assert_(not line) # Must be at EOF f.close() finally: - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def drive_one(self, pattern): for length in lengths: @@ -59,7 +59,7 @@ class BufferSizeTest(unittest.TestCase): self.drive_one(bytes(1000)) def test_main(): - test_support.run_unittest(BufferSizeTest) + support.run_unittest(BufferSizeTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index a74cc84be4..ef562db54c 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1,7 +1,7 @@ # Python test set -- built-in functions -import test.test_support, unittest -from test.test_support import fcmp, TESTFN, unlink, run_unittest, \ +import test.support, unittest +from test.support import fcmp, TESTFN, unlink, run_unittest, \ run_with_locale from operator import neg diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 5f3580d23b..206dde935b 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -13,7 +13,7 @@ import pickle import tempfile import unittest import warnings -import test.test_support +import test.support import test.string_tests import test.buffer_tests @@ -969,13 +969,13 @@ class ByteArraySubclassTest(unittest.TestCase): def test_main(): - test.test_support.run_unittest(BytesTest) - test.test_support.run_unittest(ByteArrayTest) - test.test_support.run_unittest(AssortedBytesTest) - test.test_support.run_unittest(BytesAsStringTest) - test.test_support.run_unittest(ByteArrayAsStringTest) - test.test_support.run_unittest(ByteArraySubclassTest) - test.test_support.run_unittest(BytearrayPEP3137Test) + test.support.run_unittest(BytesTest) + test.support.run_unittest(ByteArrayTest) + test.support.run_unittest(AssortedBytesTest) + test.support.run_unittest(BytesAsStringTest) + test.support.run_unittest(ByteArrayAsStringTest) + test.support.run_unittest(ByteArraySubclassTest) + test.support.run_unittest(BytearrayPEP3137Test) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py index 39bf19c329..4646f02ac1 100644 --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from test import test_support -from test.test_support import TESTFN +from test import support +from test.support import TESTFN import unittest from io import BytesIO @@ -333,13 +333,13 @@ class FuncTest(BaseTest): self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) def test_main(): - test_support.run_unittest( + support.run_unittest( BZ2FileTest, BZ2CompressorTest, BZ2DecompressorTest, FuncTest ) - test_support.reap_children() + support.reap_children() if __name__ == '__main__': test_main() diff --git a/Lib/test/test_cProfile.py b/Lib/test/test_cProfile.py index 7ae0bca678..913ed1adee 100644 --- a/Lib/test/test_cProfile.py +++ b/Lib/test/test_cProfile.py @@ -121,7 +121,7 @@ class C: def test_main(): - from test.test_support import TestSkipped + from test.support import TestSkipped raise TestSkipped('test_cProfile test is current broken') diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index 5f9c0571ba..5debee9b88 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -1,7 +1,7 @@ import calendar import unittest -from test import test_support +from test import support result_2004_text = """ @@ -383,7 +383,7 @@ class SundayTestCase(MonthCalendarTestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( OutputTestCase, CalendarTestCase, MondayTestCase, diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py index 2652343ee1..c00ccbac85 100644 --- a/Lib/test/test_call.py +++ b/Lib/test/test_call.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support # The test cases here cover several paths through the function calling # code. They depend on the METH_XXX flag that is used to define a C @@ -124,7 +124,7 @@ class CFunctionCalls(unittest.TestCase): def test_main(): - test_support.run_unittest(CFunctionCalls) + support.run_unittest(CFunctionCalls) if __name__ == "__main__": diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 87be9ee775..df5ce0b658 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -2,7 +2,7 @@ # these are all functions _testcapi exports whose name begins with 'test_'. import sys -from test import test_support +from test import support import _testcapi def test_main(): @@ -10,13 +10,13 @@ def test_main(): for name in dir(_testcapi): if name.startswith('test_'): test = getattr(_testcapi, name) - if test_support.verbose: + if support.verbose: print("internal", name) test() # some extra thread-state tests driven via _testcapi def TestThreadState(): - if test_support.verbose: + if support.verbose: print("auto-thread-state") idents = [] @@ -29,7 +29,7 @@ def test_main(): time.sleep(1) # Check our main thread is in the list exactly 3 times. if idents.count(thread.get_ident()) != 3: - raise test_support.TestFailed( + raise support.TestFailed( "Couldn't find main thread correctly in the list") try: diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 70bf0acf63..dcc1a9807f 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -3,7 +3,7 @@ import io import unittest import collections -from test import test_support +from test import support class SortedDict(collections.UserDict): def items(self): @@ -251,7 +251,7 @@ class TestCaseBase(unittest.TestCase): cf.set("sect", "option2", "splat") def test_read_returns_file_list(self): - file1 = test_support.findfile("cfgparser.1") + file1 = support.findfile("cfgparser.1") # check when we pass a mix of readable and non-readable files: cf = self.newconfig() parsed_files = cf.read([file1, "nonexistant-file"]) @@ -469,7 +469,7 @@ class SortedTestCase(RawConfigParserTestCase): "o4 = 1\n\n") def test_main(): - test_support.run_unittest( + support.run_unittest( ConfigParserTestCase, RawConfigParserTestCase, SafeConfigParserTestCase, diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py index f28719bd99..f9b336f7e5 100644 --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest +from test.support import run_unittest import cgi import os import sys diff --git a/Lib/test/test_charmapcodec.py b/Lib/test/test_charmapcodec.py index 5e4055eec9..8b79bdef82 100644 --- a/Lib/test/test_charmapcodec.py +++ b/Lib/test/test_charmapcodec.py @@ -9,7 +9,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com). """#" -import test.test_support, unittest +import test.support, unittest import codecs @@ -50,7 +50,7 @@ class CharmapCodecTest(unittest.TestCase): self.assertRaises(UnicodeError, str, b'abc\001', codecname) def test_main(): - test.test_support.run_unittest(CharmapCodecTest) + test.support.run_unittest(CharmapCodecTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py index 730826db86..cabf715dcb 100644 --- a/Lib/test/test_class.py +++ b/Lib/test/test_class.py @@ -2,7 +2,7 @@ import unittest -from test import test_support +from test import support testmeths = [ @@ -555,7 +555,7 @@ class ClassTests(unittest.TestCase): hash(a.f) def test_main(): - test_support.run_unittest(ClassTests) + support.run_unittest(ClassTests) if __name__=='__main__': test_main() diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py index ca4945d18c..3c34fecd90 100755 --- a/Lib/test/test_cmath.py +++ b/Lib/test/test_cmath.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest +from test.support import run_unittest from test.test_math import parse_testfile, test_file import unittest import os, sys diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py index 2c77931071..e2b3022a2a 100644 --- a/Lib/test/test_cmd.py +++ b/Lib/test/test_cmd.py @@ -167,8 +167,8 @@ class samplecmdclass(cmd.Cmd): return True def test_main(verbose=None): - from test import test_support, test_cmd - test_support.run_doctest(test_cmd, verbose) + from test import support, test_cmd + support.run_doctest(test_cmd, verbose) def test_coverage(coverdir): tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 19089a44aa..9ccf3f5041 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -2,7 +2,7 @@ # All tests are executed with environment variables ignored # See test_cmd_line_script.py for testing of script execution -import test.test_support, unittest +import test.support, unittest import sys import subprocess @@ -123,8 +123,8 @@ class CmdLineTest(unittest.TestCase): def test_main(): - test.test_support.run_unittest(CmdLineTest) - test.test_support.reap_children() + test.support.run_unittest(CmdLineTest) + test.support.reap_children() if __name__ == "__main__": test_main() diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index 74031c9be1..e0b09ea8ee 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -4,7 +4,7 @@ import unittest import os import os.path import sys -import test.test_support +import test.support import tempfile import subprocess import py_compile @@ -12,9 +12,9 @@ import contextlib import shutil import zipfile -verbose = test.test_support.verbose +verbose = test.support.verbose -# XXX ncoghlan: Should we consider moving these to test_support? +# XXX ncoghlan: Should we consider moving these to support? from test.test_cmd_line import _spawn_python, _kill_python def _run_python(*args): @@ -176,8 +176,8 @@ class CmdLineTest(unittest.TestCase): def test_main(): - test.test_support.run_unittest(CmdLineTest) - test.test_support.reap_children() + test.support.run_unittest(CmdLineTest) + test.support.reap_children() if __name__ == '__main__': test_main() diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 63378c22ed..c8fa2a138b 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -119,7 +119,7 @@ def dump(co): print("consts:", tuple(consts(co.co_consts))) def test_main(verbose=None): - from test.test_support import run_doctest + from test.support import run_doctest from test import test_code run_doctest(test_code, verbose) diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 64d1645dbb..d1a48688f8 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -1,4 +1,4 @@ -import test.test_support, unittest +import test.support, unittest import sys, codecs, html.entities, unicodedata class PosReturn: @@ -843,7 +843,7 @@ class CodecCallbackTest(unittest.TestCase): self.assertRaises(TypeError, data.decode, encoding, "test.replacing") def test_main(): - test.test_support.run_unittest(CodecCallbackTest) + test.support.run_unittest(CodecCallbackTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecencodings_cn.py b/Lib/test/test_codecencodings_cn.py index bc1d7add15..77bac139cf 100644 --- a/Lib/test/test_codecencodings_cn.py +++ b/Lib/test/test_codecencodings_cn.py @@ -4,7 +4,7 @@ # Codec encoding tests for PRC encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -51,7 +51,7 @@ class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase): has_iso10646 = True def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecencodings_hk.py b/Lib/test/test_codecencodings_hk.py index c8e794114a..b1deb715a5 100644 --- a/Lib/test/test_codecencodings_hk.py +++ b/Lib/test/test_codecencodings_hk.py @@ -4,7 +4,7 @@ # Codec encoding tests for HongKong encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -21,7 +21,7 @@ class Test_Big5HKSCS(test_multibytecodec_support.TestBase, unittest.TestCase): ) def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecencodings_jp.py b/Lib/test/test_codecencodings_jp.py index 5d939a64cb..e2cd7d7020 100644 --- a/Lib/test/test_codecencodings_jp.py +++ b/Lib/test/test_codecencodings_jp.py @@ -4,7 +4,7 @@ # Codec encoding tests for Japanese encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -99,7 +99,7 @@ class Test_SJISX0213(test_multibytecodec_support.TestBase, unittest.TestCase): ) def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecencodings_kr.py b/Lib/test/test_codecencodings_kr.py index 18ed3934c3..34fade923e 100644 --- a/Lib/test/test_codecencodings_kr.py +++ b/Lib/test/test_codecencodings_kr.py @@ -4,7 +4,7 @@ # Codec encoding tests for ROK encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -63,7 +63,7 @@ class Test_JOHAB(test_multibytecodec_support.TestBase, unittest.TestCase): ) def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecencodings_tw.py b/Lib/test/test_codecencodings_tw.py index bb7fd3822e..6b840d36ce 100644 --- a/Lib/test/test_codecencodings_tw.py +++ b/Lib/test/test_codecencodings_tw.py @@ -4,7 +4,7 @@ # Codec encoding tests for ROC encodings. # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -21,7 +21,7 @@ class Test_Big5(test_multibytecodec_support.TestBase, unittest.TestCase): ) def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecmaps_cn.py b/Lib/test/test_codecmaps_cn.py index 344fc562f7..34a910d876 100644 --- a/Lib/test/test_codecmaps_cn.py +++ b/Lib/test/test_codecmaps_cn.py @@ -4,7 +4,7 @@ # Codec mapping tests for PRC encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -27,7 +27,7 @@ class TestGB18030Map(test_multibytecodec_support.TestBase_Mapping, def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecmaps_hk.py b/Lib/test/test_codecmaps_hk.py index 362ab7fafc..ddb1208b3d 100644 --- a/Lib/test/test_codecmaps_hk.py +++ b/Lib/test/test_codecmaps_hk.py @@ -4,7 +4,7 @@ # Codec mapping tests for HongKong encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -14,8 +14,8 @@ class TestBig5HKSCSMap(test_multibytecodec_support.TestBase_Mapping, mapfileurl = 'http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT' def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": - test_support.use_resources = ['urlfetch'] + support.use_resources = ['urlfetch'] test_main() diff --git a/Lib/test/test_codecmaps_jp.py b/Lib/test/test_codecmaps_jp.py index dec97fb75f..75db00c602 100644 --- a/Lib/test/test_codecmaps_jp.py +++ b/Lib/test/test_codecmaps_jp.py @@ -4,7 +4,7 @@ # Codec mapping tests for Japanese encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -61,7 +61,7 @@ class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping, def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecmaps_kr.py b/Lib/test/test_codecmaps_kr.py index f9c97e5b49..0da9d1ce95 100644 --- a/Lib/test/test_codecmaps_kr.py +++ b/Lib/test/test_codecmaps_kr.py @@ -4,7 +4,7 @@ # Codec mapping tests for ROK encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -38,7 +38,7 @@ class TestJOHABMap(test_multibytecodec_support.TestBase_Mapping, pass_dectest = [(b'\\', '\u20a9')] def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecmaps_tw.py b/Lib/test/test_codecmaps_tw.py index 4bd1966298..e6df3a72fc 100644 --- a/Lib/test/test_codecmaps_tw.py +++ b/Lib/test/test_codecmaps_tw.py @@ -4,7 +4,7 @@ # Codec mapping tests for ROC encodings # -from test import test_support +from test import support from test import test_multibytecodec_support import unittest @@ -25,7 +25,7 @@ class TestCP950Map(test_multibytecodec_support.TestBase_Mapping, ] def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index a828edfa6e..a7da809ccb 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import codecs import sys, _testcapi, io @@ -1032,7 +1032,7 @@ class NameprepTest(unittest.TestCase): try: self.assertEquals(nameprep(orig), prepped) except Exception as e: - raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e))) + raise support.TestFailed("Test 3.%d: %s" % (pos+1, str(e))) class IDNACodecTest(unittest.TestCase): def test_builtin_decode(self): @@ -1477,7 +1477,7 @@ class WithStmtTest(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( UTF32Test, UTF32LETest, UTF32BETest, diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py index edea601117..224a314195 100644 --- a/Lib/test/test_codeop.py +++ b/Lib/test/test_codeop.py @@ -3,7 +3,7 @@ Nick Mathewson """ import unittest -from test.test_support import run_unittest, is_jython +from test.support import run_unittest, is_jython from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT import io diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py index b1664f4f1d..ade8bdfde9 100644 --- a/Lib/test/test_coding.py +++ b/Lib/test/test_coding.py @@ -1,6 +1,6 @@ -import test.test_support, unittest -from test.test_support import TESTFN, unlink +import test.support, unittest +from test.support import TESTFN, unlink import os, sys class CodingTest(unittest.TestCase): @@ -50,7 +50,7 @@ class CodingTest(unittest.TestCase): sys.path.pop(0) def test_main(): - test.test_support.run_unittest(CodingTest) + test.support.run_unittest(CodingTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 93847444fe..ad8c2302dd 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -1,7 +1,7 @@ """Unit tests for collections.py.""" import unittest, doctest -from test import test_support +from test import support from collections import namedtuple from collections import Hashable, Iterable, Iterator from collections import Sized, Container, Callable @@ -321,8 +321,8 @@ import doctest, collections def test_main(verbose=None): NamedTupleDocs = doctest.DocTestSuite(module=collections) test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs, TestCollectionABCs] - test_support.run_unittest(*test_classes) - test_support.run_doctest(collections, verbose) + support.run_unittest(*test_classes) + support.run_doctest(collections, verbose) if __name__ == "__main__": diff --git a/Lib/test/test_colorsys.py b/Lib/test/test_colorsys.py index a8cd885db1..e405b8a4d0 100644 --- a/Lib/test/test_colorsys.py +++ b/Lib/test/test_colorsys.py @@ -1,4 +1,4 @@ -import unittest, test.test_support +import unittest, test.support import colorsys def frange(start, stop, step): @@ -70,7 +70,7 @@ class ColorsysTest(unittest.TestCase): self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls)) def test_main(): - test.test_support.run_unittest(ColorsysTest) + test.support.run_unittest(ColorsysTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py index 1b84306092..b4e48ced7d 100644 --- a/Lib/test/test_commands.py +++ b/Lib/test/test_commands.py @@ -5,7 +5,7 @@ import unittest import os, tempfile, re -from test.test_support import TestSkipped, run_unittest, reap_children +from test.support import TestSkipped, run_unittest, reap_children from commands import * # The module says: diff --git a/Lib/test/test_compare.py b/Lib/test/test_compare.py index de32f3cc40..ee3794ae9a 100644 --- a/Lib/test/test_compare.py +++ b/Lib/test/test_compare.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support class Empty: def __repr__(self): @@ -61,7 +61,7 @@ class ComparisonTest(unittest.TestCase): def test_main(): - test_support.run_unittest(ComparisonTest) + support.run_unittest(ComparisonTest) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 5a069d3607..2462269b26 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -1,7 +1,7 @@ import unittest import sys import _ast -from test import test_support +from test import support class TestSpecifics(unittest.TestCase): @@ -444,7 +444,7 @@ if 1: def test_main(): - test_support.run_unittest(TestSpecifics) + support.run_unittest(TestSpecifics) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index fbed4f285c..44c8999b6f 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -1,5 +1,5 @@ import unittest, os -from test import test_support +from test import support from random import random from math import atan2 @@ -339,16 +339,16 @@ class ComplexTest(unittest.TestCase): fo = None try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") print(a, b, file=fo) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), ("%s %s\n" % (a, b))) finally: if (fo is not None) and (not fo.closed): fo.close() try: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) except (OSError, IOError): pass @@ -360,7 +360,7 @@ class ComplexTest(unittest.TestCase): self.assertEquals(atan2(z2.imag, -1.), atan2(-0., -1.)) def test_main(): - test_support.run_unittest(ComplexTest) + support.run_unittest(ComplexTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_contains.py b/Lib/test/test_contains.py index 5ab80e489d..e570787448 100644 --- a/Lib/test/test_contains.py +++ b/Lib/test/test_contains.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest +from test.support import run_unittest import unittest diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py index 51d2436ee8..c05f37b0ba 100644 --- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -8,7 +8,7 @@ import tempfile import unittest import threading from contextlib import * # Tests __all__ -from test import test_support +from test import support class ContextManagerTestCase(unittest.TestCase): @@ -331,7 +331,7 @@ class LockContextTestCase(unittest.TestCase): # This is needed to make the test actually run under regrtest.py! def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_cookie.py b/Lib/test/test_cookie.py index e4c8975818..07d29e1473 100644 --- a/Lib/test/test_cookie.py +++ b/Lib/test/test_cookie.py @@ -1,6 +1,6 @@ # Simple test suite for Cookie.py -from test.test_support import run_unittest, run_doctest +from test.support import run_unittest, run_doctest import unittest import Cookie diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_cookielib.py index 87f118d1e1..e400bfab41 100644 --- a/Lib/test/test_cookielib.py +++ b/Lib/test/test_cookielib.py @@ -3,7 +3,7 @@ import re, os, time from unittest import TestCase -from test import test_support +from test import support class DateTimeTests(TestCase): @@ -234,7 +234,7 @@ class FileCookieJarTests(TestCase): def test_lwp_valueless_cookie(self): # cookies with no value should be saved and loaded consistently from cookielib import LWPCookieJar - filename = test_support.TESTFN + filename = support.TESTFN c = LWPCookieJar() interact_netscape(c, "http://www.acme.com/", 'boo') self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None) @@ -250,7 +250,7 @@ class FileCookieJarTests(TestCase): def test_bad_magic(self): from cookielib import LWPCookieJar, MozillaCookieJar, LoadError # IOErrors (eg. file doesn't exist) are allowed to propagate - filename = test_support.TESTFN + filename = support.TESTFN for cookiejar_class in LWPCookieJar, MozillaCookieJar: c = cookiejar_class() try: @@ -356,7 +356,7 @@ class CookieTests(TestCase): # missing = sign in Cookie: header is regarded by Mozilla as a missing # name, and by cookielib as a missing value - filename = test_support.TESTFN + filename = support.TESTFN c = MozillaCookieJar(filename) interact_netscape(c, "http://www.acme.com/", 'eggs') interact_netscape(c, "http://www.acme.com/", '"spam"; path=/foo/') @@ -1505,7 +1505,7 @@ class LWPCookieTests(TestCase): self.assertEquals(len(c), 6) # save and restore - filename = test_support.TESTFN + filename = support.TESTFN try: c.save(filename, ignore_discard=True) @@ -1547,7 +1547,7 @@ class LWPCookieTests(TestCase): year_plus_one = time.localtime()[0] + 1 - filename = test_support.TESTFN + filename = support.TESTFN c = MozillaCookieJar(filename, policy=DefaultCookiePolicy(rfc2965=True)) @@ -1722,7 +1722,7 @@ class LWPCookieTests(TestCase): def test_main(verbose=None): - test_support.run_unittest( + support.run_unittest( DateTimeTests, HeaderTests, CookieTests, diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py index 182b8c3dc6..500fa83f11 100644 --- a/Lib/test/test_copy.py +++ b/Lib/test/test_copy.py @@ -4,7 +4,7 @@ import copy import copyreg import unittest -from test import test_support +from test import support class TestCopy(unittest.TestCase): @@ -50,7 +50,7 @@ class TestCopy(unittest.TestCase): def __reduce_ex__(self, proto): return "" def __reduce__(self): - raise test_support.TestFailed("shouldn't call this") + raise support.TestFailed("shouldn't call this") x = C() y = copy.copy(x) self.assert_(y is x) @@ -223,7 +223,7 @@ class TestCopy(unittest.TestCase): def __reduce_ex__(self, proto): return "" def __reduce__(self): - raise test_support.TestFailed("shouldn't call this") + raise support.TestFailed("shouldn't call this") x = C() y = copy.deepcopy(x) self.assert_(y is x) @@ -584,7 +584,7 @@ class TestCopy(unittest.TestCase): def global_foo(x, y): return x+y def test_main(): - test_support.run_unittest(TestCopy) + support.run_unittest(TestCopy) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_copyreg.py b/Lib/test/test_copyreg.py index 82f6c94e89..48e58ea29e 100644 --- a/Lib/test/test_copyreg.py +++ b/Lib/test/test_copyreg.py @@ -1,7 +1,7 @@ import copyreg import unittest -from test import test_support +from test import support from test.pickletester import ExtensionSaver class C: @@ -114,7 +114,7 @@ class CopyRegTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(CopyRegTestCase) + support.run_unittest(CopyRegTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py index aa07f495db..b4d0ac97c6 100755 --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import crypt @@ -6,11 +6,11 @@ class CryptTestCase(unittest.TestCase): def test_crypt(self): c = crypt.crypt('mypassword', 'ab') - if test_support.verbose: + if support.verbose: print('Test encryption: ', c) def test_main(): - test_support.run_unittest(CryptTestCase) + support.run_unittest(CryptTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index f53c5ea36f..1dbb71a8bb 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -10,7 +10,7 @@ from io import StringIO, BytesIO from tempfile import TemporaryFile import csv import gc -from test import test_support +from test import support class Test_Csv(unittest.TestCase): """ @@ -790,7 +790,7 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back self.assertEqual(dialect.quotechar, "'") if not hasattr(sys, "gettotalrefcount"): - if test_support.verbose: print("*** skipping leakage tests ***") + if support.verbose: print("*** skipping leakage tests ***") else: class NUL: def write(s, *args): @@ -891,7 +891,7 @@ class TestUnicode(unittest.TestCase): def test_main(): mod = sys.modules[__name__] - test_support.run_unittest( + support.run_unittest( *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')] ) diff --git a/Lib/test/test_ctypes.py b/Lib/test/test_ctypes.py index 7a81ab4c55..92c98ada28 100644 --- a/Lib/test/test_ctypes.py +++ b/Lib/test/test_ctypes.py @@ -1,6 +1,6 @@ import unittest -from test.test_support import run_unittest +from test.support import run_unittest import ctypes.test def test_main(): diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index d50d81dfe4..ebeb926320 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -16,7 +16,7 @@ import curses.panel # 'curses' resource be given on the regrtest command line using the -u # option. If not available, nothing after this line will be executed. -from test.test_support import requires, TestSkipped +from test.support import requires, TestSkipped requires('curses') # XXX: if newterm was supported we could use it instead of initscr and not exit diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index e83048ec78..2048fa0a42 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -7,7 +7,7 @@ import os import pickle import unittest -from test import test_support +from test import support from datetime import MINYEAR, MAXYEAR from datetime import timedelta @@ -3340,7 +3340,7 @@ class Oddballs(unittest.TestCase): self.assertEqual(datetime_sc, as_datetime) def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py index 44b712c3c6..2c6ce9902a 100755 --- a/Lib/test/test_dbm.py +++ b/Lib/test/test_dbm.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import os import random @@ -8,13 +8,13 @@ from dbm import error class DbmTestCase(unittest.TestCase): def setUp(self): - self.filename = test_support.TESTFN + self.filename = support.TESTFN self.d = dbm.open(self.filename, 'c') self.d.close() def tearDown(self): for suffix in ['', '.pag', '.dir', '.db']: - test_support.unlink(self.filename + suffix) + support.unlink(self.filename + suffix) def test_keys(self): self.d = dbm.open(self.filename, 'c') @@ -34,7 +34,7 @@ class DbmTestCase(unittest.TestCase): self.fail() def test_main(): - test_support.run_unittest(DbmTestCase) + support.run_unittest(DbmTestCase) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index b4f942ec0b..617f4d97cf 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -30,7 +30,7 @@ import os, sys import pickle, copy import unittest from decimal import * -from test.test_support import (TestSkipped, run_unittest, run_doctest, +from test.support import (TestSkipped, run_unittest, run_doctest, is_resource_enabled) import random try: diff --git a/Lib/test/test_decorators.py b/Lib/test/test_decorators.py index 1499004154..53c9469112 100644 --- a/Lib/test/test_decorators.py +++ b/Lib/test/test_decorators.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support def funcattrs(**kwds): def decorate(func): @@ -302,8 +302,8 @@ class TestClassDecorators(unittest.TestCase): self.assertEqual(C.extra, 'second') def test_main(): - test_support.run_unittest(TestDecorators) - test_support.run_unittest(TestClassDecorators) + support.run_unittest(TestDecorators) + support.run_unittest(TestClassDecorators) if __name__=="__main__": test_main() diff --git a/Lib/test/test_defaultdict.py b/Lib/test/test_defaultdict.py index 065cc10203..49519ab06a 100644 --- a/Lib/test/test_defaultdict.py +++ b/Lib/test/test_defaultdict.py @@ -4,7 +4,7 @@ import os import copy import tempfile import unittest -from test import test_support +from test import support from collections import defaultdict @@ -166,7 +166,7 @@ class TestDefaultDict(unittest.TestCase): def test_main(): - test_support.run_unittest(TestDefaultDict) + support.run_unittest(TestDefaultDict) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py index cb5957928d..1ac43dad27 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -1,6 +1,6 @@ from collections import deque import unittest -from test import test_support, seq_tests +from test import support, seq_tests from weakref import proxy import copy import pickle @@ -64,28 +64,28 @@ class TestBasic(unittest.TestCase): self.assertEqual(list(d), [7, 8, 9]) d = deque(range(200), maxlen=10) d.append(d) - test_support.unlink(test_support.TESTFN) - fo = open(test_support.TESTFN, "w") + support.unlink(support.TESTFN) + fo = open(support.TESTFN, "w") try: fo.write(str(d)) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(d)) finally: fo.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) d = deque(range(10), maxlen=None) self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])') - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") try: fo.write(str(d)) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(d)) finally: fo.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_comparisons(self): d = deque('xabc'); d.popleft() @@ -284,15 +284,15 @@ class TestBasic(unittest.TestCase): d = deque(range(200)) d.append(d) try: - test_support.unlink(test_support.TESTFN) - fo = open(test_support.TESTFN, "w") + support.unlink(support.TESTFN) + fo = open(support.TESTFN, "w") print(d, file=fo, end='') fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(d)) finally: fo.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_init(self): self.assertRaises(TypeError, deque, 'abc', 2, 3); @@ -670,21 +670,21 @@ def test_main(verbose=None): TestSubclassWithKwargs, ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) # doctests from test import test_deque - test_support.run_doctest(test_deque, verbose) + support.run_doctest(test_deque, verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 288afd48c1..ad649cb176 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3,7 +3,7 @@ import unittest import warnings from copy import deepcopy -from test import test_support +from test import support class OperatorsTest(unittest.TestCase): @@ -2449,12 +2449,12 @@ order (MRO) for bases """ ## self.ateof = 1 ## return s ## - ## f = file(name=test_support.TESTFN, mode='w') + ## f = file(name=support.TESTFN, mode='w') ## lines = ['a\n', 'b\n', 'c\n'] ## try: ## f.writelines(lines) ## f.close() - ## f = CountedInput(test_support.TESTFN) + ## f = CountedInput(support.TESTFN) ## for (i, expected) in zip(range(1, 5) + [4], lines + 2 * [""]): ## got = f.readline() ## self.assertEqual(expected, got) @@ -2466,7 +2466,7 @@ order (MRO) for bases """ ## f.close() ## except: ## pass - ## test_support.unlink(test_support.TESTFN) + ## support.unlink(support.TESTFN) def test_keywords(self): # Testing keyword args to basic type constructors ... @@ -4093,7 +4093,7 @@ class PTypesLongInitTest(unittest.TestCase): def test_main(): # Run all local test cases, with PTypesLongInitTest first. - test_support.run_unittest(PTypesLongInitTest, OperatorsTest, + support.run_unittest(PTypesLongInitTest, OperatorsTest, ClassPropertiesAndMethods, DictProxyTests) if __name__ == "__main__": diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py index 1ddab0e546..bd298bdd8c 100644 --- a/Lib/test/test_descrtut.py +++ b/Lib/test/test_descrtut.py @@ -8,7 +8,7 @@ # of much interest anymore), and a few were fiddled to make the output # deterministic. -from test.test_support import sortdict +from test.support import sortdict import pprint class defaultdict(dict): @@ -473,8 +473,8 @@ def test_main(verbose=None): # into the doctest examples, and unless the full test.test_descrtut # business is used the name can change depending on how the test is # invoked. - from test import test_support, test_descrtut - test_support.run_doctest(test_descrtut, verbose) + from test import support, test_descrtut + support.run_doctest(test_descrtut, verbose) # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index 01d47da659..b518a0bb02 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import sys, collections, random, string @@ -651,7 +651,7 @@ class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol): type2test = Dict def test_main(): - test_support.run_unittest( + support.run_unittest( DictTest, GeneralMappingTests, SubclassMappingTests, diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py index 9af9e48b2c..a3b22dc450 100644 --- a/Lib/test/test_dictcomps.py +++ b/Lib/test/test_dictcomps.py @@ -36,16 +36,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_dictcomps - test_support.run_doctest(test_dictcomps, verbose) + support.run_doctest(test_dictcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_dictcomps, verbose) + support.run_doctest(test_dictcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py index 3a5fce6e7a..34883d21c0 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support class DictSetTest(unittest.TestCase): @@ -70,7 +70,7 @@ class DictSetTest(unittest.TestCase): self.assertEqual(len(values), 2) def test_main(): - test_support.run_unittest(DictSetTest) + support.run_unittest(DictSetTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py index b5168dd709..8425a20886 100644 --- a/Lib/test/test_difflib.py +++ b/Lib/test/test_difflib.py @@ -1,5 +1,5 @@ import difflib -from test.test_support import run_unittest, findfile +from test.support import run_unittest, findfile import unittest import doctest import sys diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index ceb7509825..cf62ecfdfe 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1,6 +1,6 @@ # Minimal tests for dis module -from test.test_support import run_unittest +from test.support import run_unittest import unittest import sys import dis diff --git a/Lib/test/test_distutils.py b/Lib/test/test_distutils.py index fcd792d945..94e59bc58a 100644 --- a/Lib/test/test_distutils.py +++ b/Lib/test/test_distutils.py @@ -6,11 +6,11 @@ be run. """ import distutils.tests -import test.test_support +import test.support def test_main(): - test.test_support.run_unittest(distutils.tests.test_suite()) + test.support.run_unittest(distutils.tests.test_suite()) if __name__ == "__main__": diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index af70162aa7..f07da75011 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -2,7 +2,7 @@ Test script for doctest. """ -from test import test_support +from test import support import doctest import warnings @@ -2291,10 +2291,10 @@ using the optional keyword argument `encoding`: def test_main(): # Check the doctest cases in doctest itself: - test_support.run_doctest(doctest, verbosity=True) + support.run_doctest(doctest, verbosity=True) # Check the doctest cases defined here: from test import test_doctest - test_support.run_doctest(test_doctest, verbosity=True) + support.run_doctest(test_doctest, verbosity=True) import trace, sys, re, io def test_coverage(coverdir): diff --git a/Lib/test/test_doctest2.py b/Lib/test/test_doctest2.py index eb39ab980e..86334d70d8 100644 --- a/Lib/test/test_doctest2.py +++ b/Lib/test/test_doctest2.py @@ -12,7 +12,7 @@ the example. It should be ignored: """ -from test import test_support +from test import support class C(object): """Class C. @@ -107,9 +107,9 @@ class C(object): def test_main(): from test import test_doctest2 EXPECTED = 19 - f, t = test_support.run_doctest(test_doctest2) + f, t = support.run_doctest(test_doctest2) if t != EXPECTED: - raise test_support.TestFailed("expected %d tests to run, not %d" % + raise support.TestFailed("expected %d tests to run, not %d" % (EXPECTED, t)) # Pollute the namespace with a bunch of imported functions and classes, diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py index c9984b36af..2af20716b0 100644 --- a/Lib/test/test_docxmlrpc.py +++ b/Lib/test/test_docxmlrpc.py @@ -1,6 +1,6 @@ from DocXMLRPCServer import DocXMLRPCServer import httplib -from test import test_support +from test import support import threading import time import unittest @@ -145,7 +145,7 @@ b"""<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp</strong></a>( response.read()) def test_main(): - test_support.run_unittest(DocXMLRPCHTTPGETServer) + support.run_unittest(DocXMLRPCHTTPGETServer) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dumbdbm.py index 9a2cb682a0..24c178ffd9 100644 --- a/Lib/test/test_dumbdbm.py +++ b/Lib/test/test_dumbdbm.py @@ -7,9 +7,9 @@ import io import os import unittest import dumbdbm -from test import test_support +from test import support -_fname = test_support.TESTFN +_fname = support.TESTFN def _delete_files(): for ext in [".dir", ".dat", ".bak"]: @@ -177,7 +177,7 @@ class DumbDBMTestCase(unittest.TestCase): def test_main(): try: - test_support.run_unittest(DumbDBMTestCase) + support.run_unittest(DumbDBMTestCase) finally: _delete_files() diff --git a/Lib/test/test_dummy_thread.py b/Lib/test/test_dummy_thread.py index 59104587f9..585711f22b 100644 --- a/Lib/test/test_dummy_thread.py +++ b/Lib/test/test_dummy_thread.py @@ -10,7 +10,7 @@ import time import queue import random import unittest -from test import test_support +from test import support DELAY = 0 # Set > 0 when testing a module other than dummy_thread, such as # the 'thread' module. @@ -71,13 +71,13 @@ class LockTests(unittest.TestCase): self.lock.acquire() start_time = int(time.time()) _thread.start_new_thread(delay_unlock,(self.lock, DELAY)) - if test_support.verbose: + if support.verbose: print() print("*** Waiting for thread to release the lock "\ "(approx. %s sec.) ***" % DELAY) self.lock.acquire() end_time = int(time.time()) - if test_support.verbose: + if support.verbose: print("done") self.failUnless((end_time - start_time) >= DELAY, "Blocking by unconditional acquiring failed.") @@ -149,7 +149,7 @@ class ThreadTests(unittest.TestCase): thread_count = 5 testing_queue = queue.Queue(thread_count) - if test_support.verbose: + if support.verbose: print() print("*** Testing multiple thread creation "\ "(will take approx. %s to %s sec.) ***" % (DELAY, thread_count)) @@ -161,7 +161,7 @@ class ThreadTests(unittest.TestCase): _thread.start_new_thread(queue_mark, (testing_queue, local_delay)) time.sleep(DELAY) - if test_support.verbose: + if support.verbose: print('done') self.failUnless(testing_queue.qsize() == thread_count, "Not all %s threads executed properly after %s sec." % @@ -172,10 +172,10 @@ def test_main(imported_module=None): if imported_module: _thread = imported_module DELAY = 2 - if test_support.verbose: + if support.verbose: print() print("*** Using %s as _thread module ***" % _thread) - test_support.run_unittest(LockTests, MiscTests, ThreadTests) + support.run_unittest(LockTests, MiscTests, ThreadTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_dummy_threading.py b/Lib/test/test_dummy_threading.py index 2d0dadd4cc..4e983ce4b6 100644 --- a/Lib/test/test_dummy_threading.py +++ b/Lib/test/test_dummy_threading.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import dummy_threading as _threading import time @@ -15,20 +15,20 @@ class DummyThreadingTestCase(unittest.TestCase): # module. #delay = random.random() * 2 delay = 0 - if test_support.verbose: + if support.verbose: print('task', self.getName(), 'will run for', delay, 'sec') sema.acquire() mutex.acquire() running += 1 - if test_support.verbose: + if support.verbose: print(running, 'tasks are running') mutex.release() time.sleep(delay) - if test_support.verbose: + if support.verbose: print('task', self.getName(), 'done') mutex.acquire() running -= 1 - if test_support.verbose: + if support.verbose: print(self.getName(), 'is finished.', running, 'tasks are running') mutex.release() sema.release() @@ -49,15 +49,15 @@ class DummyThreadingTestCase(unittest.TestCase): self.threads.append(t) t.start() - if test_support.verbose: + if support.verbose: print('waiting for all tasks to complete') for t in self.threads: t.join() - if test_support.verbose: + if support.verbose: print('all tasks done') def test_main(): - test_support.run_unittest(DummyThreadingTestCase) + support.run_unittest(DummyThreadingTestCase) if __name__ == '__main__': diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py index e12cbd36f4..f0a18e71d0 100644 --- a/Lib/test/test_email.py +++ b/Lib/test/test_email.py @@ -3,10 +3,10 @@ # The specific tests now live in Lib/email/test from email.test.test_email import suite -from test import test_support +from test import support def test_main(): - test_support.run_unittest(suite()) + support.run_unittest(suite()) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py index f5c568995b..cdb9e7e411 100644 --- a/Lib/test/test_enumerate.py +++ b/Lib/test/test_enumerate.py @@ -1,7 +1,7 @@ import unittest import sys -from test import test_support +from test import support class G: 'Sequence using __getitem__' @@ -215,14 +215,14 @@ class TestLongStart(EnumerateTestCase): def test_main(verbose=None): testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig, TestReversed) - test_support.run_unittest(*testclasses) + support.run_unittest(*testclasses) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*testclasses) + support.run_unittest(*testclasses) counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_eof.py b/Lib/test/test_eof.py index 91fd845551..4e37560a3d 100644 --- a/Lib/test/test_eof.py +++ b/Lib/test/test_eof.py @@ -2,7 +2,7 @@ """test script for a few new invalid token catches""" import unittest -from test import test_support +from test import support class EOFTestCase(unittest.TestCase): def test_EOFC(self): @@ -13,7 +13,7 @@ class EOFTestCase(unittest.TestCase): except SyntaxError as msg: self.assertEqual(str(msg), expect) else: - raise test_support.TestFailed + raise support.TestFailed def test_EOFS(self): expect = ("EOF while scanning triple-quoted string literal " @@ -23,10 +23,10 @@ class EOFTestCase(unittest.TestCase): except SyntaxError as msg: self.assertEqual(str(msg), expect) else: - raise test_support.TestFailed + raise support.TestFailed def test_main(): - test_support.run_unittest(EOFTestCase) + support.run_unittest(EOFTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py index 1e30d61c50..b1ca322669 100644 --- a/Lib/test/test_epoll.py +++ b/Lib/test/test_epoll.py @@ -29,15 +29,15 @@ import select import tempfile import unittest -from test import test_support +from test import support if not hasattr(select, "epoll"): - raise test_support.TestSkipped("test works only on Linux 2.6") + raise support.TestSkipped("test works only on Linux 2.6") try: select.epoll() except IOError as e: if e.errno == errno.ENOSYS: - raise test_support.TestSkipped("kernel doesn't support epoll()") + raise support.TestSkipped("kernel doesn't support epoll()") class TestEPoll(unittest.TestCase): @@ -189,7 +189,7 @@ class TestEPoll(unittest.TestCase): ep.unregister(fd) def test_main(): - test_support.run_unittest(TestEPoll) + support.run_unittest(TestEPoll) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_errno.py b/Lib/test/test_errno.py index 30771910af..28425e2057 100755 --- a/Lib/test/test_errno.py +++ b/Lib/test/test_errno.py @@ -4,7 +4,7 @@ """ import errno -from test import test_support +from test import support import unittest std_c_errors = frozenset(['EDOM', 'ERANGE']) @@ -33,7 +33,7 @@ class ErrorcodeTests(unittest.TestCase): def test_main(): - test_support.run_unittest(ErrnoAttributeTests, ErrorcodeTests) + support.run_unittest(ErrnoAttributeTests, ErrorcodeTests) if __name__ == '__main__': diff --git a/Lib/test/test_exception_variations.py b/Lib/test/test_exception_variations.py index 5bcb8fce0a..11f5e5c84e 100644 --- a/Lib/test/test_exception_variations.py +++ b/Lib/test/test_exception_variations.py @@ -1,5 +1,5 @@ -from test.test_support import run_unittest +from test.support import run_unittest import unittest class ExceptionTestCase(unittest.TestCase): diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 0574356d13..619b7e3234 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -6,7 +6,7 @@ import unittest import pickle import weakref -from test.test_support import TESTFN, unlink, run_unittest +from test.support import TESTFN, unlink, run_unittest # XXX This is not really enough, each *operation* should be tested! diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py index 3cf7ac2df2..7ed0e2e119 100644 --- a/Lib/test/test_extcall.py +++ b/Lib/test/test_extcall.py @@ -11,10 +11,10 @@ We're defining four helper functions ... print(a, b) >>> def f(*a, **k): - ... print(a, test_support.sortdict(k)) + ... print(a, support.sortdict(k)) >>> def g(x, *y, **z): - ... print(x, y, test_support.sortdict(z)) + ... print(x, y, support.sortdict(z)) >>> def h(j=1, a=2, h=3): ... print(j, a, h) @@ -245,11 +245,11 @@ TypeError if te dictionary is not empty """ -from test import test_support +from test import support def test_main(): from test import test_extcall # self import - test_support.run_doctest(test_extcall, True) + support.run_doctest(test_extcall, True) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index 136961237a..afb511cd06 100755 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -8,7 +8,7 @@ import os import struct import sys import unittest -from test.test_support import verbose, TESTFN, unlink, run_unittest +from test.support import verbose, TESTFN, unlink, run_unittest # TODO - Write tests for flock() and lockf(). diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index 5102de3e44..ff4996ae48 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -4,7 +4,7 @@ import unittest from array import array from weakref import proxy -from test.test_support import TESTFN, findfile, run_unittest +from test.support import TESTFN, findfile, run_unittest from collections import UserList class AutoFileTests(unittest.TestCase): diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py index 53b949d832..22f0be7844 100644 --- a/Lib/test/test_filecmp.py +++ b/Lib/test/test_filecmp.py @@ -1,13 +1,13 @@ import os, filecmp, shutil, tempfile, shutil import unittest -from test import test_support +from test import support class FileCompareTestCase(unittest.TestCase): def setUp(self): - self.name = test_support.TESTFN - self.name_same = test_support.TESTFN + '-same' - self.name_diff = test_support.TESTFN + '-diff' + self.name = support.TESTFN + self.name_same = support.TESTFN + '-same' + self.name_diff = support.TESTFN + '-diff' data = 'Contents of file go here.\n' for name in [self.name, self.name_same, self.name_diff]: output = open(name, 'w') @@ -128,7 +128,7 @@ class DirCompareTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(FileCompareTestCase, DirCompareTestCase) + support.run_unittest(FileCompareTestCase, DirCompareTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py index 76a41a65f6..a4d59e1240 100644 --- a/Lib/test/test_fileinput.py +++ b/Lib/test/test_fileinput.py @@ -4,8 +4,8 @@ Nick Mathewson ''' import unittest -from test.test_support import verbose, TESTFN, run_unittest -from test.test_support import unlink as safe_unlink +from test.support import verbose, TESTFN, run_unittest +from test.support import unlink as safe_unlink import sys, re from io import StringIO from fileinput import FileInput, hook_encoded diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 2f9c23f69e..c94ceafdea 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -6,7 +6,7 @@ import unittest from array import array from weakref import proxy -from test.test_support import TESTFN, findfile, run_unittest +from test.support import TESTFN, findfile, run_unittest from collections import UserList import _fileio diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 5653c16070..d17400c657 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -1,7 +1,7 @@ import unittest, struct import os -from test import test_support +from test import support import math from math import isinf, isnan import operator @@ -28,7 +28,7 @@ class GeneralFloatCases(unittest.TestCase): # Implementation limitation in PyFloat_FromString() self.assertRaises(ValueError, float, unicode("1"*10000)) - @test_support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') + @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') def test_float_with_comma(self): # set locale to something that doesn't use '.' for the decimal point # float must not accept the locale specific decimal point but @@ -361,7 +361,7 @@ class InfNanTest(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( FormatFunctionsTestCase, UnknownFormatTestCase, IEEEFormatTestCase, diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py index 9abcbd6f28..c593704e67 100644 --- a/Lib/test/test_fnmatch.py +++ b/Lib/test/test_fnmatch.py @@ -1,6 +1,6 @@ """Test cases for the fnmatch module.""" -from test import test_support +from test import support import unittest from fnmatch import fnmatch, fnmatchcase @@ -39,7 +39,7 @@ class FnmatchTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(FnmatchTestCase) + support.run_unittest(FnmatchTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py index 221a14d273..e6d9eed237 100644 --- a/Lib/test/test_fork1.py +++ b/Lib/test/test_fork1.py @@ -4,7 +4,7 @@ import os import time from test.fork_wait import ForkWait -from test.test_support import TestSkipped, run_unittest, reap_children +from test.support import TestSkipped, run_unittest, reap_children try: os.fork diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index cbb7be837a..fb914756a1 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -1,9 +1,9 @@ -from test.test_support import verbose, TestFailed +from test.support import verbose, TestFailed import sys -import test.test_support as test_support +import test.support as support import unittest -maxsize = test_support.MAX_Py_ssize_t +maxsize = support.MAX_Py_ssize_t # test string formatting operator (I am not sure if this is being tested # elsewhere but, surely, some of the given cases are *not* tested because @@ -256,7 +256,7 @@ class FormatTest(unittest.TestCase): raise TestFailed('"%*d"%(maxsize, -127) should fail') def test_main(): - test_support.run_unittest(FormatTest) + support.run_unittest(FormatTest) if __name__ == "__main__": diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py index 21c176107c..d06c2062c9 100644 --- a/Lib/test/test_fractions.py +++ b/Lib/test/test_fractions.py @@ -1,7 +1,7 @@ """Tests for Lib/fractions.py.""" from decimal import Decimal -from test.test_support import run_unittest +from test.support import run_unittest import math import operator import fractions diff --git a/Lib/test/test_frozen.py b/Lib/test/test_frozen.py index de45b23a37..545941bedc 100644 --- a/Lib/test/test_frozen.py +++ b/Lib/test/test_frozen.py @@ -1,6 +1,6 @@ # Test the frozen module defined in frozen.c. -from test.test_support import captured_stdout, run_unittest +from test.support import captured_stdout, run_unittest import unittest import sys, os diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 0204c6f5e4..b91588a310 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -4,9 +4,9 @@ import ftplib import time from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST # This function sets the evt 3 times: # 1) when the connection is ready to be accepted. @@ -37,7 +37,7 @@ class GeneralTests(TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(3) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) threading.Thread(target=server, args=(self.evt,self.sock)).start() # Wait for the server to be ready. self.evt.wait() @@ -106,7 +106,7 @@ class GeneralTests(TestCase): def test_main(verbose=None): - test_support.run_unittest(GeneralTests) + support.run_unittest(GeneralTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index 7385f96385..5e9f7d3aff 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import types import unittest @@ -225,7 +225,7 @@ class FunctionDocstringTest(FuncAttrsTest): self.assertEqual(self.b.__doc__, None) def test_main(): - test_support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest, + support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest, ArbitraryFunctionAttrTest, FunctionDictsTest, FunctionDocstringTest) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index a1e5d13af3..84e974a8db 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1,6 +1,6 @@ import functools import unittest -from test import test_support +from test import support from weakref import proxy @staticmethod @@ -347,14 +347,14 @@ def test_main(verbose=None): TestWraps, TestReduce ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py index 1437489d90..494f539a36 100644 --- a/Lib/test/test_future.py +++ b/Lib/test/test_future.py @@ -1,7 +1,7 @@ # Test various flavors of legal and illegal future statements import unittest -from test import test_support +from test import support import re rx = re.compile('\((\S+).py, line (\d+)') @@ -13,17 +13,17 @@ def get_error_location(msg): class FutureTest(unittest.TestCase): def test_future1(self): - test_support.unload('test_future1') + support.unload('test_future1') from test import test_future1 self.assertEqual(test_future1.result, 6) def test_future2(self): - test_support.unload('test_future2') + support.unload('test_future2') from test import test_future2 self.assertEqual(test_future2.result, 6) def test_future3(self): - test_support.unload('test_future3') + support.unload('test_future3') from test import test_future3 def test_badfuture3(self): @@ -104,7 +104,7 @@ class FutureTest(unittest.TestCase): def test_main(): - test_support.run_unittest(FutureTest) + support.run_unittest(FutureTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_future3.py b/Lib/test/test_future3.py index ed23567a76..b1552a5e8e 100644 --- a/Lib/test/test_future3.py +++ b/Lib/test/test_future3.py @@ -2,7 +2,7 @@ from __future__ import nested_scopes from __future__ import division import unittest -from test import test_support +from test import support x = 2 def nester(): @@ -24,7 +24,7 @@ class TestFuture(unittest.TestCase): self.assertEqual(nester(), 3) def test_main(): - test_support.run_unittest(TestFuture) + support.run_unittest(TestFuture) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_future4.py b/Lib/test/test_future4.py index 8ada489acb..c32f27f616 100644 --- a/Lib/test/test_future4.py +++ b/Lib/test/test_future4.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals import unittest -from test import test_support +from test import support def test_main(): pass diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 9d5e0ea6d0..414e17aa8f 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import verbose, run_unittest +from test.support import verbose, run_unittest import sys import gc import weakref diff --git a/Lib/test/test_gdbm.py b/Lib/test/test_gdbm.py index 17a7f632cf..42cb136ac5 100755 --- a/Lib/test/test_gdbm.py +++ b/Lib/test/test_gdbm.py @@ -1,7 +1,7 @@ import gdbm import unittest import os -from test.test_support import verbose, TESTFN, run_unittest, unlink +from test.support import verbose, TESTFN, run_unittest, unlink filename = TESTFN diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 56f23db042..8f2da7d9e3 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -1885,8 +1885,8 @@ __test__ = {"tut": tutorial_tests, # Note that doctest and regrtest both look in sys.argv for a "-v" argument, # so this works as expected in both ways of running regrtest. def test_main(verbose=None): - from test import test_support, test_generators - test_support.run_doctest(test_generators, verbose) + from test import support, test_generators + support.run_doctest(test_generators, verbose) # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py index d91271446c..9d0baeb8c2 100644 --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import os import genericpath @@ -27,114 +27,114 @@ class AllCommonTest(unittest.TestCase): ) def test_getsize(self): - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertEqual(genericpath.getsize(test_support.TESTFN), 3) + self.assertEqual(genericpath.getsize(support.TESTFN), 3) finally: if not f.closed: f.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_time(self): - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - f = open(test_support.TESTFN, "ab") + f = open(support.TESTFN, "ab") f.write(b"bar") f.close() - f = open(test_support.TESTFN, "rb") + f = open(support.TESTFN, "rb") d = f.read() f.close() self.assertEqual(d, b"foobar") self.assert_( - genericpath.getctime(test_support.TESTFN) <= - genericpath.getmtime(test_support.TESTFN) + genericpath.getctime(support.TESTFN) <= + genericpath.getmtime(support.TESTFN) ) finally: if not f.closed: f.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_exists(self): - self.assertIs(genericpath.exists(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(genericpath.exists(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.exists(test_support.TESTFN), True) + self.assertIs(genericpath.exists(support.TESTFN), True) finally: if not f.close(): f.close() try: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) except os.error: pass self.assertRaises(TypeError, genericpath.exists) def test_isdir(self): - self.assertIs(genericpath.isdir(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(genericpath.isdir(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.isdir(test_support.TESTFN), False) - os.remove(test_support.TESTFN) - os.mkdir(test_support.TESTFN) - self.assertIs(genericpath.isdir(test_support.TESTFN), True) - os.rmdir(test_support.TESTFN) + self.assertIs(genericpath.isdir(support.TESTFN), False) + os.remove(support.TESTFN) + os.mkdir(support.TESTFN) + self.assertIs(genericpath.isdir(support.TESTFN), True) + os.rmdir(support.TESTFN) finally: if not f.close(): f.close() try: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) except os.error: pass try: - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) except os.error: pass self.assertRaises(TypeError, genericpath.isdir) def test_isfile(self): - self.assertIs(genericpath.isfile(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(genericpath.isfile(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(genericpath.isfile(test_support.TESTFN), True) - os.remove(test_support.TESTFN) - os.mkdir(test_support.TESTFN) - self.assertIs(genericpath.isfile(test_support.TESTFN), False) - os.rmdir(test_support.TESTFN) + self.assertIs(genericpath.isfile(support.TESTFN), True) + os.remove(support.TESTFN) + os.mkdir(support.TESTFN) + self.assertIs(genericpath.isfile(support.TESTFN), False) + os.rmdir(support.TESTFN) finally: if not f.close(): f.close() try: - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) except os.error: pass try: - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) except os.error: pass self.assertRaises(TypeError, genericpath.isdir) def test_samefile(self): - f = open(test_support.TESTFN + "1", "wb") + f = open(support.TESTFN + "1", "wb") try: f.write(b"foo") f.close() self.assertIs( genericpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "1" + support.TESTFN + "1", + support.TESTFN + "1" ), True ) @@ -142,24 +142,24 @@ class AllCommonTest(unittest.TestCase): # inode information and thus, that samefile() doesn't work if hasattr(os, "symlink"): os.symlink( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ) self.assertIs( genericpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ), True ) - os.remove(test_support.TESTFN + "2") - f = open(test_support.TESTFN + "2", "wb") + os.remove(support.TESTFN + "2") + f = open(support.TESTFN + "2", "wb") f.write(b"bar") f.close() self.assertIs( genericpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ), False ) @@ -167,18 +167,18 @@ class AllCommonTest(unittest.TestCase): if not f.close(): f.close() try: - os.remove(test_support.TESTFN + "1") + os.remove(support.TESTFN + "1") except os.error: pass try: - os.remove(test_support.TESTFN + "2") + os.remove(support.TESTFN + "2") except os.error: pass self.assertRaises(TypeError, genericpath.samefile) def test_main(): - test_support.run_unittest(AllCommonTest) + support.run_unittest(AllCommonTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py index 593c1c5b57..61e9fe5e70 100644 --- a/Lib/test/test_genexps.py +++ b/Lib/test/test_genexps.py @@ -262,16 +262,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_genexps - test_support.run_doctest(test_genexps, verbose) + support.run_doctest(test_genexps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_genexps, verbose) + support.run_doctest(test_genexps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py index 69791e8d7d..34d8ee03bc 100644 --- a/Lib/test/test_getargs2.py +++ b/Lib/test/test_getargs2.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support from _testcapi import getargs_keywords import warnings @@ -306,7 +306,7 @@ def test_main(): pass # PY_LONG_LONG not available else: tests.append(LongLong_TestCase) - test_support.run_unittest(*tests) + support.run_unittest(*tests) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py index 36d1688b03..de3325d7ee 100644 --- a/Lib/test/test_getopt.py +++ b/Lib/test/test_getopt.py @@ -1,7 +1,7 @@ # test_getopt.py # David Goodger <dgoodger@bigfoot.com> 2000-08-19 -from test.test_support import verbose, run_doctest, run_unittest +from test.support import verbose, run_doctest, run_unittest import unittest import getopt diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py index a875272bd3..73c9c1c146 100644 --- a/Lib/test/test_gettext.py +++ b/Lib/test/test_gettext.py @@ -4,7 +4,7 @@ import shutil import gettext import unittest -from test import test_support +from test import support # TODO: @@ -338,7 +338,7 @@ class WeirdMetadataTest(GettextBaseTest): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py index a628e6e4b2..adaea189fb 100644 --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import run_unittest, TESTFN +from test.support import run_unittest, TESTFN import glob import os import shutil diff --git a/Lib/test/test_global.py b/Lib/test/test_global.py index 2a58a10a22..823f2c544d 100644 --- a/Lib/test/test_global.py +++ b/Lib/test/test_global.py @@ -1,6 +1,6 @@ """Verify that warnings are issued for global statements following use.""" -from test.test_support import run_unittest, check_syntax_error +from test.support import run_unittest, check_syntax_error import unittest import warnings diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 94b7b312bc..1a34ff8b74 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -8,7 +8,7 @@ # regression test, the filterwarnings() call has been added to # regrtest.py. -from test.test_support import run_unittest, check_syntax_error +from test.support import run_unittest, check_syntax_error import unittest import sys # testing import * diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py index fb607f003f..5acda52e9a 100755 --- a/Lib/test/test_grp.py +++ b/Lib/test/test_grp.py @@ -2,7 +2,7 @@ import grp import unittest -from test import test_support +from test import support class GroupDatabaseTestCase(unittest.TestCase): @@ -86,7 +86,7 @@ class GroupDatabaseTestCase(unittest.TestCase): self.assertRaises(KeyError, grp.getgrgid, fakegid) def test_main(): - test_support.run_unittest(GroupDatabaseTestCase) + support.run_unittest(GroupDatabaseTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 0010112a8b..c26035bae7 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -3,7 +3,7 @@ """ import unittest -from test import test_support +from test import support import os import gzip @@ -22,13 +22,13 @@ data2 = b"""/* zlibmodule.c -- gzip-compatible data compression */ class TestGzip(unittest.TestCase): - filename = test_support.TESTFN + filename = support.TESTFN def setUp (self): - test_support.unlink(self.filename) + support.unlink(self.filename) def tearDown (self): - test_support.unlink(self.filename) + support.unlink(self.filename) def test_write (self): @@ -158,7 +158,7 @@ class TestGzip(unittest.TestCase): f.close() def test_main(verbose=None): - test_support.run_unittest(TestGzip) + support.run_unittest(TestGzip) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py index a0364f2a30..fb1699a132 100644 --- a/Lib/test/test_hash.py +++ b/Lib/test/test_hash.py @@ -3,7 +3,7 @@ # import unittest -from test import test_support +from test import support class HashEqualityTestCase(unittest.TestCase): @@ -38,7 +38,7 @@ class HashEqualityTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(HashEqualityTestCase) + support.run_unittest(HashEqualityTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index 399e50b162..912b1334c9 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -8,7 +8,7 @@ import hashlib import unittest -from test import test_support +from test import support def hexstr(s): @@ -186,7 +186,7 @@ class HashLibTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(HashLibTestCase) + support.run_unittest(HashLibTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py index 24d2992479..e41abf023c 100644 --- a/Lib/test/test_heapq.py +++ b/Lib/test/test_heapq.py @@ -2,7 +2,7 @@ import random import unittest -from test import test_support +from test import support import sys # We do a bit of trickery here to be able to test both the C implementation @@ -353,14 +353,14 @@ def test_main(verbose=None): from types import BuiltinFunctionType test_classes = [TestHeapPython, TestHeapC, TestErrorHandling] - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py index 537f29854a..43953cfeb0 100644 --- a/Lib/test/test_hmac.py +++ b/Lib/test/test_hmac.py @@ -2,7 +2,7 @@ import hmac import hashlib import unittest import warnings -from test import test_support +from test import support class TestVectorsTestCase(unittest.TestCase): @@ -211,7 +211,7 @@ class TestVectorsTestCase(unittest.TestCase): def digest(self): return self._x.digest() - with test_support.catch_warning(): + with support.catch_warning(): warnings.simplefilter('error', RuntimeWarning) try: hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash) @@ -309,7 +309,7 @@ class CopyTestCase(unittest.TestCase): "Hexdigest of copy doesn't match original hexdigest.") def test_main(): - test_support.run_unittest( + support.run_unittest( TestVectorsTestCase, ConstructorTestCase, SanityTestCase, diff --git a/Lib/test/test_htmllib.py b/Lib/test/test_htmllib.py index a20f43bbf1..61f3a139a9 100644 --- a/Lib/test/test_htmllib.py +++ b/Lib/test/test_htmllib.py @@ -2,7 +2,7 @@ import formatter import htmllib import unittest -from test import test_support +from test import support class AnchorCollector(htmllib.HTMLParser): @@ -62,7 +62,7 @@ class HTMLParserTestCase(unittest.TestCase): ]) def test_main(): - test_support.run_unittest(HTMLParserTestCase) + support.run_unittest(HTMLParserTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index a4f2c34c6c..8691cbf826 100755 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -3,7 +3,7 @@ import HTMLParser import pprint import unittest -from test import test_support +from test import support class EventCollector(HTMLParser.HTMLParser): @@ -315,7 +315,7 @@ DOCTYPE html [ def test_main(): - test_support.run_unittest(HTMLParserTestCase) + support.run_unittest(HTMLParserTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index f0e551f5eb..7a77cffde4 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -4,9 +4,9 @@ import socket from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST class FakeSocket: def __init__(self, text, fileclass=io.BytesIO): @@ -206,7 +206,7 @@ class TimeoutTest(TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - TimeoutTest.PORT = test_support.bind_port(self.serv) + TimeoutTest.PORT = support.bind_port(self.serv) self.serv.listen(5) def tearDown(self): @@ -252,7 +252,7 @@ class HTTPSTimeoutTest(TestCase): self.assertEqual(h.timeout, 30) def test_main(verbose=None): - test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, + support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, HTTPSTimeoutTest) if __name__ == '__main__': diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index ce0e075294..2105fc2dcf 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -1,7 +1,7 @@ import imaplib import time -from test import test_support +from test import support import unittest @@ -18,7 +18,7 @@ class TestImaplib(unittest.TestCase): def test_main(): - test_support.run_unittest(TestImaplib) + support.run_unittest(TestImaplib) if __name__ == "__main__": diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index 13a3bfd713..e2b9e9ab24 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -1,6 +1,6 @@ import imp import unittest -from test import test_support +from test import support class LockTests(unittest.TestCase): @@ -69,7 +69,7 @@ class ImportTests(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( LockTests, ImportTests, ) diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 1c9dd3a026..81e221dd73 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -1,4 +1,4 @@ -from test.test_support import TESTFN, run_unittest, catch_warning +from test.support import TESTFN, run_unittest, catch_warning import unittest import os @@ -8,7 +8,7 @@ import sys import py_compile import warnings import imp -from test.test_support import unlink, TESTFN, unload +from test.support import unlink, TESTFN, unload def remove_files(name): @@ -146,13 +146,13 @@ class ImportTest(unittest.TestCase): def test_import_name_binding(self): # import x.y.z binds x in the current namespace import test as x - import test.test_support + import test.support self.assert_(x is test, x.__name__) - self.assert_(hasattr(test.test_support, "__file__")) + self.assert_(hasattr(test.support, "__file__")) # import x.y.z as w binds z as w - import test.test_support as y - self.assert_(y is test.test_support, y.__name__) + import test.support as y + self.assert_(y is test.support, y.__name__) def test_import_initless_directory_warning(self): with catch_warning(): diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py index 3108bd6d25..eaf213d0c0 100644 --- a/Lib/test/test_importhooks.py +++ b/Lib/test/test_importhooks.py @@ -2,7 +2,7 @@ import sys import imp import os import unittest -from test import test_support +from test import support test_src = """\ @@ -265,7 +265,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase): pass def test_main(): - test_support.run_unittest(ImportHooksTestCase) + support.run_unittest(ImportHooksTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_index.py b/Lib/test/test_index.py index 71cfb15c0f..31609c3107 100644 --- a/Lib/test/test_index.py +++ b/Lib/test/test_index.py @@ -1,7 +1,7 @@ import unittest -from test import test_support +from test import support import operator -maxsize = test_support.MAX_Py_ssize_t +maxsize = support.MAX_Py_ssize_t minsize = -maxsize-1 class oldstyle: @@ -193,7 +193,7 @@ class OverflowTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( BaseTestCase, ListTestCase, TupleTestCase, diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index c62fa552d8..55fae20734 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -6,7 +6,7 @@ import datetime import collections from os.path import normcase -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest from test import inspect_fodder as mod from test import inspect_fodder2 as mod2 diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py index 91d52735bd..3462540e75 100644 --- a/Lib/test/test_int.py +++ b/Lib/test/test_int.py @@ -1,7 +1,7 @@ import sys import unittest -from test.test_support import run_unittest +from test.support import run_unittest L = [ ('0', 0), diff --git a/Lib/test/test_int_literal.py b/Lib/test/test_int_literal.py index 9bd0c412ce..1d578a7d71 100644 --- a/Lib/test/test_int_literal.py +++ b/Lib/test/test_int_literal.py @@ -4,7 +4,7 @@ This is complex because of changes due to PEP 237. """ import unittest -from test import test_support +from test import support class TestHexOctBin(unittest.TestCase): @@ -141,7 +141,7 @@ class TestHexOctBin(unittest.TestCase): self.assertEqual(-0b1111111111111111111111111111111111111111111111111111111111111111, -18446744073709551615) def test_main(): - test_support.run_unittest(TestHexOctBin) + support.run_unittest(TestHexOctBin) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index fa3a8bbfd6..320c7c3c6d 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -6,7 +6,7 @@ import time import array import unittest from itertools import chain -from test import test_support +from test import support import codecs import io # The module under test @@ -80,10 +80,10 @@ class MockNonBlockWriterIO(io.RawIOBase): class IOTest(unittest.TestCase): def setUp(self): - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def tearDown(self): - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def write_ops(self, f): self.assertEqual(f.write(b"blah."), 5) @@ -149,13 +149,13 @@ class IOTest(unittest.TestCase): self.assertEqual(f.read(2), b"x") def test_raw_file_io(self): - f = io.open(test_support.TESTFN, "wb", buffering=0) + f = io.open(support.TESTFN, "wb", buffering=0) self.assertEqual(f.readable(), False) self.assertEqual(f.writable(), True) self.assertEqual(f.seekable(), True) self.write_ops(f) f.close() - f = io.open(test_support.TESTFN, "rb", buffering=0) + f = io.open(support.TESTFN, "rb", buffering=0) self.assertEqual(f.readable(), True) self.assertEqual(f.writable(), False) self.assertEqual(f.seekable(), True) @@ -163,13 +163,13 @@ class IOTest(unittest.TestCase): f.close() def test_buffered_file_io(self): - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") self.assertEqual(f.readable(), False) self.assertEqual(f.writable(), True) self.assertEqual(f.seekable(), True) self.write_ops(f) f.close() - f = io.open(test_support.TESTFN, "rb") + f = io.open(support.TESTFN, "rb") self.assertEqual(f.readable(), True) self.assertEqual(f.writable(), False) self.assertEqual(f.seekable(), True) @@ -177,10 +177,10 @@ class IOTest(unittest.TestCase): f.close() def test_readline(self): - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") f.write(b"abc\ndef\nxyzzy\nfoo") f.close() - f = io.open(test_support.TESTFN, "rb") + f = io.open(support.TESTFN, "rb") self.assertEqual(f.readline(), b"abc\n") self.assertEqual(f.readline(10), b"def\n") self.assertEqual(f.readline(2), b"xy") @@ -201,7 +201,7 @@ class IOTest(unittest.TestCase): # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. if sys.platform[:3] == 'win' or sys.platform == 'darwin': - if not test_support.is_resource_enabled("largefile"): + if not support.is_resource_enabled("largefile"): print("\nTesting large file ops skipped on %s." % sys.platform, file=sys.stderr) print("It requires %d bytes and a long time." % self.LARGE, @@ -209,22 +209,22 @@ class IOTest(unittest.TestCase): print("Use 'regrtest.py -u largefile test_io' to run it.", file=sys.stderr) return - f = io.open(test_support.TESTFN, "w+b", 0) + f = io.open(support.TESTFN, "w+b", 0) self.large_file_ops(f) f.close() - f = io.open(test_support.TESTFN, "w+b") + f = io.open(support.TESTFN, "w+b") self.large_file_ops(f) f.close() def test_with_open(self): for bufsize in (0, 1, 100): f = None - with open(test_support.TESTFN, "wb", bufsize) as f: + with open(support.TESTFN, "wb", bufsize) as f: f.write(b"xxx") self.assertEqual(f.closed, True) f = None try: - with open(test_support.TESTFN, "wb", bufsize) as f: + with open(support.TESTFN, "wb", bufsize) as f: 1/0 except ZeroDivisionError: self.assertEqual(f.closed, True) @@ -243,31 +243,31 @@ class IOTest(unittest.TestCase): def flush(self): record.append(3) io.FileIO.flush(self) - f = MyFileIO(test_support.TESTFN, "w") + f = MyFileIO(support.TESTFN, "w") f.write("xxx") del f self.assertEqual(record, [1, 2, 3]) def test_close_flushes(self): - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") f.write(b"xxx") f.close() - f = io.open(test_support.TESTFN, "rb") + f = io.open(support.TESTFN, "rb") self.assertEqual(f.read(), b"xxx") f.close() def test_array_writes(self): a = array.array('i', range(10)) n = len(memoryview(a)) - f = io.open(test_support.TESTFN, "wb", 0) + f = io.open(support.TESTFN, "wb", 0) self.assertEqual(f.write(a), n) f.close() - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") self.assertEqual(f.write(a), n) f.close() def test_closefd(self): - self.assertRaises(ValueError, io.open, test_support.TESTFN, 'w', + self.assertRaises(ValueError, io.open, support.TESTFN, 'w', closefd=False) class MemorySeekTestMixin: @@ -638,10 +638,10 @@ class TextIOWrapperTest(unittest.TestCase): def setUp(self): self.testdata = b"AAA\r\nBBB\rCCC\r\nDDD\nEEE\r\n" self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ascii") - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def tearDown(self): - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def testLineBuffering(self): r = io.BytesIO() @@ -818,11 +818,11 @@ class TextIOWrapperTest(unittest.TestCase): def testBasicIO(self): for chunksize in (1, 2, 3, 4, 5, 15, 16, 17, 31, 32, 33, 63, 64, 65): for enc in "ascii", "latin1", "utf8" :# , "utf-16-be", "utf-16-le": - f = io.open(test_support.TESTFN, "w+", encoding=enc) + f = io.open(support.TESTFN, "w+", encoding=enc) f._CHUNK_SIZE = chunksize self.assertEquals(f.write("abc"), 3) f.close() - f = io.open(test_support.TESTFN, "r+", encoding=enc) + f = io.open(support.TESTFN, "r+", encoding=enc) f._CHUNK_SIZE = chunksize self.assertEquals(f.tell(), 0) self.assertEquals(f.read(), "abc") @@ -865,7 +865,7 @@ class TextIOWrapperTest(unittest.TestCase): self.assertEquals(rlines, wlines) def testTelling(self): - f = io.open(test_support.TESTFN, "w+", encoding="utf8") + f = io.open(support.TESTFN, "w+", encoding="utf8") p0 = f.tell() f.write("\xff\n") p1 = f.tell() @@ -893,10 +893,10 @@ class TextIOWrapperTest(unittest.TestCase): u_suffix = "\u8888\n" suffix = bytes(u_suffix.encode("utf-8")) line = prefix + suffix - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") f.write(line*2) f.close() - f = io.open(test_support.TESTFN, "r", encoding="utf-8") + f = io.open(support.TESTFN, "r", encoding="utf-8") s = f.read(prefix_size) self.assertEquals(s, str(prefix, "ascii")) self.assertEquals(f.tell(), prefix_size) @@ -905,10 +905,10 @@ class TextIOWrapperTest(unittest.TestCase): def testSeekingToo(self): # Regression test for a specific bug data = b'\xe0\xbf\xbf\n' - f = io.open(test_support.TESTFN, "wb") + f = io.open(support.TESTFN, "wb") f.write(data) f.close() - f = io.open(test_support.TESTFN, "r", encoding="utf-8") + f = io.open(support.TESTFN, "r", encoding="utf-8") f._CHUNK_SIZE # Just test that it exists f._CHUNK_SIZE = 2 f.readline() @@ -920,16 +920,16 @@ class TextIOWrapperTest(unittest.TestCase): def testSeekAndTellWithData(data, min_pos=0): """Tell/seek to various points within a data stream and ensure that the decoded data returned by read() is consistent.""" - f = io.open(test_support.TESTFN, 'wb') + f = io.open(support.TESTFN, 'wb') f.write(data) f.close() - f = io.open(test_support.TESTFN, encoding='test_decoder') + f = io.open(support.TESTFN, encoding='test_decoder') decoded = f.read() f.close() for i in range(min_pos, len(decoded) + 1): # seek positions for j in [1, 5, len(decoded) - i]: # read lengths - f = io.open(test_support.TESTFN, encoding='test_decoder') + f = io.open(support.TESTFN, encoding='test_decoder') self.assertEquals(f.read(i), decoded[:i]) cookie = f.tell() self.assertEquals(f.read(j), decoded[i:i + j]) @@ -985,7 +985,7 @@ class TextIOWrapperTest(unittest.TestCase): nchars = len(line) nbytes = len(line.encode(enc)) for chunk_size in (32, 64, 128, 256): - f = io.open(test_support.TESTFN, "w+", encoding=enc) + f = io.open(support.TESTFN, "w+", encoding=enc) f._CHUNK_SIZE = chunk_size t0 = timer() for i in range(nlines): @@ -1005,7 +1005,7 @@ class TextIOWrapperTest(unittest.TestCase): f.tell() t4 = timer() f.close() - if test_support.verbose: + if support.verbose: print("\nTiming test: %d lines of %d characters (%d bytes)" % (nlines, nchars, nbytes)) print("File chunk size: %6s" % f._CHUNK_SIZE) @@ -1162,7 +1162,7 @@ class MiscIOTest(unittest.TestCase): def test_main(): - test_support.run_unittest(IOTest, BytesIOTest, StringIOTest, + support.run_unittest(IOTest, BytesIOTest, StringIOTest, BufferedReaderTest, BufferedWriterTest, BufferedRWPairTest, BufferedRandomTest, StatefulIncrementalDecoderTest, diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index feea5bf4f6..e9c1d0f5d4 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import TestSkipped, run_unittest +from test.support import TestSkipped, run_unittest import os, struct try: import fcntl, termios diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py index 1e29f4c7ef..9482e75438 100644 --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -3,7 +3,7 @@ # testing of error conditions uncovered when using extension types. import unittest -from test import test_support +from test import support import sys @@ -264,7 +264,7 @@ def blowstack(fxn, arg, compare_to): def test_main(): - test_support.run_unittest( + support.run_unittest( TestIsInstanceExceptions, TestIsSubclassExceptions, TestIsInstanceIsSubclass diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py index d861dcdd66..eba9728e34 100644 --- a/Lib/test/test_iter.py +++ b/Lib/test/test_iter.py @@ -1,7 +1,7 @@ # Test iterators. import unittest -from test.test_support import run_unittest, TESTFN, unlink +from test.support import run_unittest, TESTFN, unlink # Test result of triple loop (too big to inline) TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2), diff --git a/Lib/test/test_iterlen.py b/Lib/test/test_iterlen.py index 46aefaa335..72e92a5801 100644 --- a/Lib/test/test_iterlen.py +++ b/Lib/test/test_iterlen.py @@ -42,7 +42,7 @@ enumerate(iter('abc')). """ import unittest -from test import test_support +from test import support from itertools import repeat from collections import deque from builtins import len as _len @@ -211,7 +211,7 @@ def test_main(): TestList, TestListReversed, ] - test_support.run_unittest(*unittests) + support.run_unittest(*unittests) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 335e47ddc0..3957f4192d 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1,12 +1,12 @@ import unittest -from test import test_support +from test import support from itertools import * from weakref import proxy import sys import operator import random from functools import reduce -maxsize = test_support.MAX_Py_ssize_t +maxsize = support.MAX_Py_ssize_t minsize = -maxsize-1 def lzip(*args): @@ -1391,20 +1391,20 @@ def test_main(verbose=None): test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC, RegressionTests, LengthTransparency, SubclassWithKwargsTest, TestExamples) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) # doctest the examples in the library reference - test_support.run_doctest(sys.modules[__name__], verbose) + support.run_doctest(sys.modules[__name__], verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_json.py b/Lib/test/test_json.py index 17ccdeecc4..17e1daf360 100644 --- a/Lib/test/test_json.py +++ b/Lib/test/test_json.py @@ -6,12 +6,12 @@ be run. """ import json.tests -import test.test_support +import test.support def test_main(): - test.test_support.run_unittest(json.tests.test_suite()) - test.test_support.run_doctest(json) + test.support.run_unittest(json.tests.test_suite()) + test.support.run_doctest(json) if __name__ == "__main__": diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py index e64a6cdd7c..aa7d3db894 100644 --- a/Lib/test/test_keywordonlyarg.py +++ b/Lib/test/test_keywordonlyarg.py @@ -6,7 +6,7 @@ __author__ = "Jiwon Seo" __email__ = "seojiwon at gmail dot com" import unittest -from test.test_support import run_unittest +from test.support import run_unittest def posonly_sum(pos_arg1, *arg, **kwarg): return pos_arg1 + sum(arg) + sum(kwarg.values()) diff --git a/Lib/test/test_kqueue.py b/Lib/test/test_kqueue.py index 310eb33962..ef4363301d 100644 --- a/Lib/test/test_kqueue.py +++ b/Lib/test/test_kqueue.py @@ -8,9 +8,9 @@ import select import sys import unittest -from test import test_support +from test import support if not hasattr(select, "kqueue"): - raise test_support.TestSkipped("test works only on BSD") + raise support.TestSkipped("test works only on BSD") class TestKQueue(unittest.TestCase): def test_create_queue(self): @@ -160,7 +160,7 @@ class TestKQueue(unittest.TestCase): serverSocket.close() def test_main(): - test_support.run_unittest(TestKQueue) + support.run_unittest(TestKQueue) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py index 0856346ffc..8060ea04e8 100644 --- a/Lib/test/test_largefile.py +++ b/Lib/test/test_largefile.py @@ -5,7 +5,7 @@ import os import stat import sys import unittest -from test.test_support import run_unittest, TESTFN, verbose, requires, \ +from test.support import run_unittest, TESTFN, verbose, requires, \ TestSkipped, unlink try: diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py index 161b9ddd24..9bd4496726 100644 --- a/Lib/test/test_lib2to3.py +++ b/Lib/test/test_lib2to3.py @@ -2,7 +2,7 @@ # because of running from lib2to3.tests import test_fixers, test_pytree, test_util import unittest -from test.test_support import run_unittest +from test.support import run_unittest def suite(): tests = unittest.TestSuite() diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py index 3b851176d4..5184321771 100644 --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -1,5 +1,5 @@ import sys -from test import test_support, list_tests +from test import support, list_tests class ListTest(list_tests.CommonTest): type2test = list @@ -43,7 +43,7 @@ class ListTest(list_tests.CommonTest): self.assertRaises((MemoryError, OverflowError), imul, lst, n) def test_main(verbose=None): - test_support.run_unittest(ListTest) + support.run_unittest(ListTest) # verify reference counting import sys @@ -51,7 +51,7 @@ def test_main(verbose=None): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(ListTest) + support.run_unittest(ListTest) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py index 684b716183..663ccbbe19 100644 --- a/Lib/test/test_listcomps.py +++ b/Lib/test/test_listcomps.py @@ -130,16 +130,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_listcomps - test_support.run_doctest(test_listcomps, verbose) + support.run_doctest(test_listcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_genexps, verbose) + support.run_doctest(test_genexps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) @@ -278,16 +278,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_listcomps - test_support.run_doctest(test_listcomps, verbose) + support.run_doctest(test_listcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_genexps, verbose) + support.run_doctest(test_genexps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) @@ -426,16 +426,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_listcomps - test_support.run_doctest(test_listcomps, verbose) + support.run_doctest(test_listcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_listcomps, verbose) + support.run_doctest(test_listcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index ef1f5c201e..6d130581d2 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -1,4 +1,4 @@ -from test.test_support import verbose, TestSkipped +from test.support import verbose, TestSkipped import locale import sys diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index b6da0aeff4..888ac72d73 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -38,7 +38,7 @@ import string import struct import sys import tempfile -from test.test_support import captured_stdout, run_with_locale, run_unittest +from test.support import captured_stdout, run_with_locale, run_unittest import textwrap import threading import time diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 256a1ce1be..21881c97c9 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import sys import random @@ -771,7 +771,7 @@ class LongTest(unittest.TestCase): self.assertRaises(OverflowError, int, float('nan')) def test_main(): - test_support.run_unittest(LongTest) + support.run_unittest(LongTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_long_future.py b/Lib/test/test_long_future.py index 36840b4dd6..428b03aeb4 100644 --- a/Lib/test/test_long_future.py +++ b/Lib/test/test_long_future.py @@ -4,7 +4,7 @@ from __future__ import division # trick just part of test_long into using future division. import unittest -from test.test_support import run_unittest +from test.support import run_unittest class TrueDivisionTests(unittest.TestCase): def test(self): diff --git a/Lib/test/test_longexp.py b/Lib/test/test_longexp.py index dd222a19bf..1b40d02983 100644 --- a/Lib/test/test_longexp.py +++ b/Lib/test/test_longexp.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support class LongExpText(unittest.TestCase): def test_longexp(self): @@ -8,7 +8,7 @@ class LongExpText(unittest.TestCase): self.assertEqual(len(l), REPS) def test_main(): - test_support.run_unittest(LongExpText) + support.run_unittest(LongExpText) if __name__=="__main__": test_main() diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py index 9d363758c8..38b85e5bdc 100644 --- a/Lib/test/test_macpath.py +++ b/Lib/test/test_macpath.py @@ -1,5 +1,5 @@ import macpath -from test import test_support +from test import support import unittest @@ -56,7 +56,7 @@ class MacPathTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(MacPathTestCase) + support.run_unittest(MacPathTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index 43b864c3a1..783323fb76 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -7,7 +7,7 @@ import email import email.message import re import io -from test import test_support +from test import support import unittest import mailbox import glob @@ -52,7 +52,7 @@ class TestMailbox(TestBase): _template = 'From: foo\n\n%s' def setUp(self): - self._path = test_support.TESTFN + self._path = support.TESTFN self._delete_recursively(self._path) self._box = self._factory(self._path) @@ -715,7 +715,7 @@ class _TestMboxMMDF(TestMailbox): self._box.close() self._delete_recursively(self._path) for lock_remnant in glob.glob(self._path + '.*'): - test_support.unlink(lock_remnant) + support.unlink(lock_remnant) def test_add_from_string(self): # Add a string starting with 'From ' to the mailbox @@ -938,7 +938,7 @@ class TestBabyl(TestMailbox): self._box.close() self._delete_recursively(self._path) for lock_remnant in glob.glob(self._path + '.*'): - test_support.unlink(lock_remnant) + support.unlink(lock_remnant) def test_labels(self): # Get labels from the mailbox @@ -964,7 +964,7 @@ class TestMessage(TestBase): _factory = mailbox.Message # Overridden by subclasses to reuse tests def setUp(self): - self._path = test_support.TESTFN + self._path = support.TESTFN def tearDown(self): self._delete_recursively(self._path) @@ -1580,7 +1580,7 @@ class TestProxyFileBase(TestBase): class TestProxyFile(TestProxyFileBase): def setUp(self): - self._path = test_support.TESTFN + self._path = support.TESTFN self._file = open(self._path, 'wb+') def tearDown(self): @@ -1629,7 +1629,7 @@ class TestProxyFile(TestProxyFileBase): class TestPartialFile(TestProxyFileBase): def setUp(self): - self._path = test_support.TESTFN + self._path = support.TESTFN self._file = open(self._path, 'wb+') def tearDown(self): @@ -1692,7 +1692,7 @@ class MaildirTestCase(unittest.TestCase): def setUp(self): # create a new maildir mailbox to work with: - self._dir = test_support.TESTFN + self._dir = support.TESTFN os.mkdir(self._dir) os.mkdir(os.path.join(self._dir, "cur")) os.mkdir(os.path.join(self._dir, "tmp")) @@ -1733,7 +1733,7 @@ class MaildirTestCase(unittest.TestCase): """Test an empty maildir mailbox""" # Test for regression on bug #117490: # Make sure the boxes attribute actually gets set. - self.mbox = mailbox.Maildir(test_support.TESTFN) + self.mbox = mailbox.Maildir(support.TESTFN) #self.assert_(hasattr(self.mbox, "boxes")) #self.assertEqual(len(self.mbox.boxes), 0) self.assert_(self.mbox.next() is None) @@ -1741,7 +1741,7 @@ class MaildirTestCase(unittest.TestCase): def test_nonempty_maildir_cur(self): self.createMessage("cur") - self.mbox = mailbox.Maildir(test_support.TESTFN) + self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 1) self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is None) @@ -1749,7 +1749,7 @@ class MaildirTestCase(unittest.TestCase): def test_nonempty_maildir_new(self): self.createMessage("new") - self.mbox = mailbox.Maildir(test_support.TESTFN) + self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 1) self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is None) @@ -1758,7 +1758,7 @@ class MaildirTestCase(unittest.TestCase): def test_nonempty_maildir_both(self): self.createMessage("cur") self.createMessage("new") - self.mbox = mailbox.Maildir(test_support.TESTFN) + self.mbox = mailbox.Maildir(support.TESTFN) #self.assertEqual(len(self.mbox.boxes), 2) self.assert_(self.mbox.next() is not None) self.assert_(self.mbox.next() is not None) @@ -1856,8 +1856,8 @@ def test_main(): TestMHMessage, TestBabylMessage, TestMMDFMessage, TestMessageConversion, TestProxyFile, TestPartialFile, MaildirTestCase) - test_support.run_unittest(*tests) - test_support.reap_children() + support.run_unittest(*tests) + support.reap_children() if __name__ == '__main__': diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index 838207a864..83ab852bec 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from test import test_support +from test import support import marshal import sys import unittest @@ -11,19 +11,19 @@ class HelperMixin: new = marshal.loads(marshal.dumps(sample, *extra)) self.assertEqual(sample, new) try: - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: marshal.dump(sample, f, *extra) finally: f.close() - f = open(test_support.TESTFN, "rb") + f = open(support.TESTFN, "rb") try: new = marshal.load(f) finally: f.close() self.assertEqual(sample, new) finally: - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) class IntTestCase(unittest.TestCase, HelperMixin): def test_ints(self): @@ -208,7 +208,7 @@ class BugsTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(IntTestCase, + support.run_unittest(IntTestCase, FloatTestCase, StringTestCase, CodeTestCase, diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index ff8db7c29f..f24bdb3b42 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -1,7 +1,7 @@ # Python test set -- math module # XXXX Should not do tests around zero only -from test.test_support import run_unittest, verbose +from test.support import run_unittest, verbose import unittest import math import os diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index 7857587850..2d91cbdeac 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -4,7 +4,7 @@ BytesIO -- for bytes """ import unittest -from test import test_support +from test import support import io import sys @@ -408,7 +408,7 @@ def test_main(): tests = [PyBytesIOTest, PyStringIOTest] if has_c_implementation: tests.extend([CBytesIOTest]) - test_support.run_unittest(*tests) + support.run_unittest(*tests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py index 27adc5ec61..b3d478df17 100644 --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -4,7 +4,7 @@ XXX We need more tests! Some tests are in test_bytes """ import unittest -import test.test_support +import test.support class MemoryviewTest(unittest.TestCase): @@ -18,7 +18,7 @@ class MemoryviewTest(unittest.TestCase): self.assertRaises(TypeError, memoryview, ob, argument=True) def test_main(): - test.test_support.run_unittest(MemoryviewTest) + test.support.run_unittest(MemoryviewTest) if __name__ == "__main__": diff --git a/Lib/test/test_metaclass.py b/Lib/test/test_metaclass.py index 733418ef95..d8195dde49 100644 --- a/Lib/test/test_metaclass.py +++ b/Lib/test/test_metaclass.py @@ -235,9 +235,9 @@ Make sure it works with subclassing. __test__ = {'doctests' : doctests} def test_main(verbose=False): - from test import test_support + from test import support from test import test_metaclass - test_support.run_doctest(test_metaclass, verbose) + support.run_doctest(test_metaclass, verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_mimetools.py b/Lib/test/test_mimetools.py index ef333f567d..1dc9178887 100644 --- a/Lib/test/test_mimetools.py +++ b/Lib/test/test_mimetools.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import string, mimetools import io @@ -70,7 +70,7 @@ class MimeToolsTest(unittest.TestCase): self.assertEqual(msg.getencoding(), "8bit") def test_main(): - test_support.run_unittest(MimeToolsTest) + support.run_unittest(MimeToolsTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 53de072d92..9651a60132 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -2,7 +2,7 @@ import mimetypes import io import unittest -from test import test_support +from test import support # Tell it we don't know about external files: mimetypes.knownfiles = [] @@ -63,7 +63,7 @@ class MimeTypesTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest(MimeTypesTestCase) + support.run_unittest(MimeTypesTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 9ea60a9cea..20130c3d72 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -4,7 +4,7 @@ import os import sys import pickle from io import StringIO -from test.test_support import verbose, run_unittest, TestSkipped +from test.support import verbose, run_unittest, TestSkipped import unittest import xml.dom diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index f01b9df4f7..0b5202a4a3 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1,4 +1,4 @@ -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest import mmap import unittest import os, re diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py index 35c765ecc8..45556e827b 100644 --- a/Lib/test/test_module.py +++ b/Lib/test/test_module.py @@ -1,6 +1,6 @@ # Test the module type import unittest -from test.test_support import run_unittest +from test.support import run_unittest import sys ModuleType = type(sys) diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py index 80c06d7c30..85bc6697b1 100644 --- a/Lib/test/test_modulefinder.py +++ b/Lib/test/test_modulefinder.py @@ -4,7 +4,7 @@ import unittest import distutils.dir_util import tempfile -from test import test_support +from test import support try: set except NameError: from sets import Set as set @@ -258,7 +258,7 @@ class ModuleFinderTest(unittest.TestCase): def test_main(): distutils.log.set_threshold(distutils.log.WARN) - test_support.run_unittest(ModuleFinderTest) + support.run_unittest(ModuleFinderTest) if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py index 615ad8b055..0eb422ea76 100644 --- a/Lib/test/test_multibytecodec.py +++ b/Lib/test/test_multibytecodec.py @@ -4,9 +4,9 @@ # Unit test for multibytecodec itself # -from test import test_support +from test import support from test import test_multibytecodec_support -from test.test_support import TESTFN +from test.support import TESTFN import unittest, io, codecs, sys, os ALL_CJKENCODINGS = [ @@ -51,7 +51,7 @@ class Test_MultibyteCodec(unittest.TestCase): print('# coding:', enc, file=io.open(TESTFN, 'w')) exec(open(TESTFN).read()) finally: - test_support.unlink(TESTFN) + support.unlink(TESTFN) class Test_IncrementalEncoder(unittest.TestCase): @@ -151,7 +151,7 @@ class Test_StreamReader(unittest.TestCase): finally: f.close() finally: - test_support.unlink(TESTFN) + support.unlink(TESTFN) class Test_StreamWriter(unittest.TestCase): if len('\U00012345') == 2: # UCS2 @@ -235,7 +235,7 @@ class Test_ISO2022(unittest.TestCase): myunichr(x).encode('iso_2022_jp', 'ignore') def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py index 5508c9d09c..3e0476e41c 100644 --- a/Lib/test/test_multibytecodec_support.py +++ b/Lib/test/test_multibytecodec_support.py @@ -6,7 +6,7 @@ import sys, codecs import unittest, re -from test import test_support +from test import support from io import BytesIO class TestBase: @@ -279,10 +279,10 @@ class TestBase_Mapping(unittest.TestCase): try: self.open_mapping_file() # test it to report the error early except IOError: - raise test_support.TestSkipped("Could not retrieve "+self.mapfileurl) + raise support.TestSkipped("Could not retrieve "+self.mapfileurl) def open_mapping_file(self): - return test_support.open_urlresource(self.mapfileurl) + return support.open_urlresource(self.mapfileurl) def test_mapping_file(self): if self.mapfileurl.endswith('.xml'): diff --git a/Lib/test/test_mutants.py b/Lib/test/test_mutants.py index 7fff78417c..b43fa47626 100644 --- a/Lib/test/test_mutants.py +++ b/Lib/test/test_mutants.py @@ -1,4 +1,4 @@ -from test.test_support import verbose, TESTFN +from test.support import verbose, TESTFN import random import os diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py index 4a2cb0ded0..938e255e41 100644 --- a/Lib/test/test_netrc.py +++ b/Lib/test/test_netrc.py @@ -1,6 +1,6 @@ import netrc, os, unittest, sys -from test import test_support +from test import support TEST_NETRC = """ machine foo login log1 password pass1 account acct1 @@ -17,7 +17,7 @@ default login log2 password pass2 """ -temp_filename = test_support.TESTFN +temp_filename = support.TESTFN class NetrcTestCase(unittest.TestCase): @@ -41,7 +41,7 @@ class NetrcTestCase(unittest.TestCase): self.assert_(nrc.hosts['default'] == ('log2', None, 'pass2')) def test_main(): - test_support.run_unittest(NetrcTestCase) + support.run_unittest(NetrcTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_nis.py b/Lib/test/test_nis.py index 757edd6c2f..8a7efcf50c 100644 --- a/Lib/test/test_nis.py +++ b/Lib/test/test_nis.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import nis @@ -8,7 +8,7 @@ class NisTests(unittest.TestCase): maps = nis.maps() except nis.error as msg: # NIS is probably not active, so this test isn't useful - if test_support.verbose: + if support.verbose: print("Test Skipped:", msg) # Can't raise TestSkipped as regrtest only recognizes the exception # import time. @@ -37,7 +37,7 @@ class NisTests(unittest.TestCase): break def test_main(): - test_support.run_unittest(NisTests) + support.run_unittest(NisTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py index ae49996baf..920ce278b7 100644 --- a/Lib/test/test_normalization.py +++ b/Lib/test/test_normalization.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest, open_urlresource +from test.support import run_unittest, open_urlresource import unittest import sys diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 627b1675e4..fa40db8961 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -1,7 +1,7 @@ import ntpath import os -from test.test_support import verbose, TestFailed -import test.test_support as test_support +from test.support import verbose, TestFailed +import test.support as support import unittest @@ -180,7 +180,7 @@ class TestNtpath(unittest.TestCase): def test_main(): - test_support.run_unittest(TestNtpath) + support.run_unittest(TestNtpath) if __name__ == "__main__": diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py index d65c5cca53..42ba600843 100644 --- a/Lib/test/test_opcodes.py +++ b/Lib/test/test_opcodes.py @@ -1,6 +1,6 @@ # Python test set -- part 2, opcodes -from test.test_support import run_unittest +from test.support import run_unittest import unittest class OpcodeTest(unittest.TestCase): diff --git a/Lib/test/test_openpty.py b/Lib/test/test_openpty.py index f9354967ab..9272c85495 100644 --- a/Lib/test/test_openpty.py +++ b/Lib/test/test_openpty.py @@ -1,7 +1,7 @@ # Test to see if openpty works. (But don't worry if it isn't available.) import os, unittest -from test.test_support import run_unittest, TestSkipped +from test.support import run_unittest, TestSkipped if not hasattr(os, "openpty"): raise TestSkipped("No openpty() available.") diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index d6146ee851..2a02dac2f6 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -1,7 +1,7 @@ import operator import unittest -from test import test_support +from test import support class Seq1: def __init__(self, lst): @@ -465,14 +465,14 @@ def test_main(verbose=None): OperatorTestCase, ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py index 71de8695db..be2867c5ff 100644 --- a/Lib/test/test_optparse.py +++ b/Lib/test/test_optparse.py @@ -15,7 +15,7 @@ import copy import unittest from io import StringIO -from test import test_support +from test import support from optparse import make_option, Option, IndentedHelpFormatter, \ @@ -1004,10 +1004,10 @@ class TestExtendAddTypes(BaseTest): self.parser.add_option("-f", "--file", type="file", dest="file") def tearDown(self): - if os.path.isdir(test_support.TESTFN): - os.rmdir(test_support.TESTFN) - elif os.path.isfile(test_support.TESTFN): - os.unlink(test_support.TESTFN) + if os.path.isdir(support.TESTFN): + os.rmdir(support.TESTFN) + elif os.path.isfile(support.TESTFN): + os.unlink(support.TESTFN) class MyOption (Option): def check_file(option, opt, value): @@ -1022,21 +1022,21 @@ class TestExtendAddTypes(BaseTest): TYPE_CHECKER["file"] = check_file def test_filetype_ok(self): - open(test_support.TESTFN, "w").close() - self.assertParseOK(["--file", test_support.TESTFN, "-afoo"], - {'file': test_support.TESTFN, 'a': 'foo'}, + open(support.TESTFN, "w").close() + self.assertParseOK(["--file", support.TESTFN, "-afoo"], + {'file': support.TESTFN, 'a': 'foo'}, []) def test_filetype_noexist(self): - self.assertParseFail(["--file", test_support.TESTFN, "-afoo"], + self.assertParseFail(["--file", support.TESTFN, "-afoo"], "%s: file does not exist" % - test_support.TESTFN) + support.TESTFN) def test_filetype_notfile(self): - os.mkdir(test_support.TESTFN) - self.assertParseFail(["--file", test_support.TESTFN, "-afoo"], + os.mkdir(support.TESTFN) + self.assertParseFail(["--file", support.TESTFN, "-afoo"], "%s: not a regular file" % - test_support.TESTFN) + support.TESTFN) class TestExtendAddActions(BaseTest): @@ -1611,7 +1611,7 @@ class TestParseNumber(BaseTest): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 503244a24f..f0b734ebd5 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -6,22 +6,22 @@ import os import unittest import warnings import sys -from test import test_support +from test import support # Tests creating TESTFN class FileTests(unittest.TestCase): def setUp(self): - if os.path.exists(test_support.TESTFN): - os.unlink(test_support.TESTFN) + if os.path.exists(support.TESTFN): + os.unlink(support.TESTFN) tearDown = setUp def test_access(self): - f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR) + f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR) os.close(f) - self.assert_(os.access(test_support.TESTFN, os.W_OK)) + self.assert_(os.access(support.TESTFN, os.W_OK)) def test_closerange(self): - f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR) + f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR) # close a fd that is open, and one that isn't os.closerange(f, f+2) self.assertRaises(OSError, os.write, f, "a") @@ -29,12 +29,12 @@ class FileTests(unittest.TestCase): class TemporaryFileTests(unittest.TestCase): def setUp(self): self.files = [] - os.mkdir(test_support.TESTFN) + os.mkdir(support.TESTFN) def tearDown(self): for name in self.files: os.unlink(name) - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) def check_tempfile(self, name): # make sure it doesn't already exist: @@ -51,10 +51,10 @@ class TemporaryFileTests(unittest.TestCase): r"test_os$") self.check_tempfile(os.tempnam()) - name = os.tempnam(test_support.TESTFN) + name = os.tempnam(support.TESTFN) self.check_tempfile(name) - name = os.tempnam(test_support.TESTFN, "pfx") + name = os.tempnam(support.TESTFN, "pfx") self.assert_(os.path.basename(name)[:3] == "pfx") self.check_tempfile(name) @@ -137,15 +137,15 @@ class TemporaryFileTests(unittest.TestCase): # Test attributes on return values from os.*stat* family. class StatAttributeTests(unittest.TestCase): def setUp(self): - os.mkdir(test_support.TESTFN) - self.fname = os.path.join(test_support.TESTFN, "f1") + os.mkdir(support.TESTFN) + self.fname = os.path.join(support.TESTFN, "f1") f = open(self.fname, 'wb') f.write(b"ABC") f.close() def tearDown(self): os.unlink(self.fname) - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) def test_stat_attributes(self): if not hasattr(os, "stat"): @@ -261,11 +261,11 @@ class StatAttributeTests(unittest.TestCase): def test_utime_dir(self): delta = 1000000 - st = os.stat(test_support.TESTFN) + st = os.stat(support.TESTFN) # round to int, because some systems may support sub-second # time stamps in stat, but not in utime. - os.utime(test_support.TESTFN, (st.st_atime, int(st.st_mtime-delta))) - st2 = os.stat(test_support.TESTFN) + os.utime(support.TESTFN, (st.st_atime, int(st.st_mtime-delta))) + st2 = os.stat(support.TESTFN) self.assertEquals(st2.st_mtime, int(st.st_mtime-delta)) # Restrict test to Win32, since there is no guarantee other @@ -280,7 +280,7 @@ class StatAttributeTests(unittest.TestCase): if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)): return buf.value - if get_file_system(test_support.TESTFN) == "NTFS": + if get_file_system(support.TESTFN) == "NTFS": def test_1565150(self): t1 = 1159195039.25 os.utime(self.fname, (t1, t1)) @@ -364,7 +364,7 @@ class WalkTests(unittest.TestCase): # link/ a symlink to TESTFN.2 # TEST2/ # tmp4 a lone file - walk_path = join(test_support.TESTFN, "TEST1") + walk_path = join(support.TESTFN, "TEST1") sub1_path = join(walk_path, "SUB1") sub11_path = join(sub1_path, "SUB11") sub2_path = join(walk_path, "SUB2") @@ -372,8 +372,8 @@ class WalkTests(unittest.TestCase): tmp2_path = join(sub1_path, "tmp2") tmp3_path = join(sub2_path, "tmp3") link_path = join(sub2_path, "link") - t2_path = join(test_support.TESTFN, "TEST2") - tmp4_path = join(test_support.TESTFN, "TEST2", "tmp4") + t2_path = join(support.TESTFN, "TEST2") + tmp4_path = join(support.TESTFN, "TEST2", "tmp4") # Create stuff. os.makedirs(sub11_path) @@ -442,7 +442,7 @@ class WalkTests(unittest.TestCase): # Windows, which doesn't have a recursive delete command. The # (not so) subtlety is that rmdir will fail unless the dir's # kids are removed first, so bottom up is essential. - for root, dirs, files in os.walk(test_support.TESTFN, topdown=False): + for root, dirs, files in os.walk(support.TESTFN, topdown=False): for name in files: os.remove(os.path.join(root, name)) for name in dirs: @@ -451,14 +451,14 @@ class WalkTests(unittest.TestCase): os.rmdir(dirname) else: os.remove(dirname) - os.rmdir(test_support.TESTFN) + os.rmdir(support.TESTFN) class MakedirTests(unittest.TestCase): def setUp(self): - os.mkdir(test_support.TESTFN) + os.mkdir(support.TESTFN) def test_makedir(self): - base = test_support.TESTFN + base = support.TESTFN path = os.path.join(base, 'dir1', 'dir2', 'dir3') os.makedirs(path) # Should work path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4') @@ -473,12 +473,12 @@ class MakedirTests(unittest.TestCase): os.makedirs(path) def tearDown(self): - path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3', + path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', 'dir6') # If the tests failed, the bottom-most directory ('../dir6') # may not have been created, so we look for the outermost directory # that exists. - while not os.path.exists(path) and path != test_support.TESTFN: + while not os.path.exists(path) and path != support.TESTFN: path = os.path.dirname(path) os.removedirs(path) @@ -511,32 +511,32 @@ class ExecTests(unittest.TestCase): class Win32ErrorTests(unittest.TestCase): def test_rename(self): - self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") + self.assertRaises(WindowsError, os.rename, support.TESTFN, support.TESTFN+".bak") def test_remove(self): - self.assertRaises(WindowsError, os.remove, test_support.TESTFN) + self.assertRaises(WindowsError, os.remove, support.TESTFN) def test_chdir(self): - self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + self.assertRaises(WindowsError, os.chdir, support.TESTFN) def test_mkdir(self): - self.assertRaises(WindowsError, os.chdir, test_support.TESTFN) + self.assertRaises(WindowsError, os.chdir, support.TESTFN) def test_utime(self): - self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None) + self.assertRaises(WindowsError, os.utime, support.TESTFN, None) def test_access(self): - self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + self.assertRaises(WindowsError, os.utime, support.TESTFN, 0) def test_chmod(self): - self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0) + self.assertRaises(WindowsError, os.utime, support.TESTFN, 0) if sys.platform != 'win32': class Win32ErrorTests(unittest.TestCase): pass def test_main(): - test_support.run_unittest( + support.run_unittest( FileTests, StatAttributeTests, EnvironTests, diff --git a/Lib/test/test_ossaudiodev.py b/Lib/test/test_ossaudiodev.py index 8f9bf6f1a6..6f8de97ccc 100644 --- a/Lib/test/test_ossaudiodev.py +++ b/Lib/test/test_ossaudiodev.py @@ -1,7 +1,7 @@ -from test import test_support -test_support.requires('audio') +from test import support +support.requires('audio') -from test.test_support import findfile, TestSkipped +from test.support import findfile, TestSkipped import errno import ossaudiodev @@ -167,7 +167,7 @@ def test_main(): raise TestSkipped(msg) raise dsp.close() - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 7269ccb012..e4179620e7 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -1,7 +1,7 @@ import parser import unittest import sys -from test import test_support +from test import support # # First, we test that we can generate trees from valid source fragments, @@ -471,7 +471,7 @@ class ParserStackLimitTestCase(unittest.TestCase): self.assertRaises(MemoryError, parser.expr, e) def test_main(): - test_support.run_unittest( + support.run_unittest( RoundtripLegalSyntaxTestCase, IllegalSyntaxTestCase, CompileTestCase, diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index faa55233db..f3e240e8f8 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -220,16 +220,16 @@ class TestTranforms(unittest.TestCase): def test_main(verbose=None): import sys - from test import test_support + from test import support test_classes = (TestTranforms,) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_pep247.py b/Lib/test/test_pep247.py index 947896938f..733109a16e 100644 --- a/Lib/test/test_pep247.py +++ b/Lib/test/test_pep247.py @@ -6,7 +6,7 @@ for hashing algorithms import hmac import unittest from hashlib import md5, sha1, sha224, sha256, sha384, sha512 -from test import test_support +from test import support class Pep247Test(unittest.TestCase): @@ -62,7 +62,7 @@ class Pep247Test(unittest.TestCase): self.check_module(hmac, key=b'abc') def test_main(): - test_support.run_unittest(Pep247Test) + support.run_unittest(Pep247Test) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_pep263.py b/Lib/test/test_pep263.py index 92065c9fe1..17abbd807a 100644 --- a/Lib/test/test_pep263.py +++ b/Lib/test/test_pep263.py @@ -2,7 +2,7 @@ # This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
import unittest
-from test import test_support
+from test import support
class PEP263Test(unittest.TestCase):
@@ -32,7 +32,7 @@ class PEP263Test(unittest.TestCase): self.fail()
def test_main():
- test_support.run_unittest(PEP263Test)
+ support.run_unittest(PEP263Test)
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py index 770b526275..eac5138494 100644 --- a/Lib/test/test_pep277.py +++ b/Lib/test/test_pep277.py @@ -1,9 +1,9 @@ # Test the Unicode versions of normal file functions # open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir import sys, os, unittest -from test import test_support +from test import support if not os.path.supports_unicode_filenames: - raise test_support.TestSkipped("test works only on NT+") + raise support.TestSkipped("test works only on NT+") filenames = [ 'abc', @@ -28,11 +28,11 @@ def deltree(dirname): os.rmdir(dirname) class UnicodeFileTests(unittest.TestCase): - files = [os.path.join(test_support.TESTFN, f) for f in filenames] + files = [os.path.join(support.TESTFN, f) for f in filenames] def setUp(self): try: - os.mkdir(test_support.TESTFN) + os.mkdir(support.TESTFN) except OSError: pass for name in self.files: @@ -42,17 +42,17 @@ class UnicodeFileTests(unittest.TestCase): os.stat(name) def tearDown(self): - deltree(test_support.TESTFN) + deltree(support.TESTFN) def _apply_failure(self, fn, filename, expected_exception, check_fn_in_exception = True): try: fn(filename) - raise test_support.TestFailed("Expected to fail calling '%s(%r)'" + raise support.TestFailed("Expected to fail calling '%s(%r)'" % (fn.__name__, filename)) except expected_exception as details: if check_fn_in_exception and details.filename != filename: - raise test_support.TestFailed("Function '%s(%r) failed with " + raise support.TestFailed("Function '%s(%r) failed with " "bad filename in the exception: %r" % (fn.__name__, filename, details.filename)) @@ -77,10 +77,10 @@ class UnicodeFileTests(unittest.TestCase): os.stat(name) def test_listdir(self): - f1 = os.listdir(test_support.TESTFN) - f2 = os.listdir(str(test_support.TESTFN.encode("utf-8"), + f1 = os.listdir(support.TESTFN) + f2 = os.listdir(str(support.TESTFN.encode("utf-8"), sys.getfilesystemencoding())) - sf2 = set("\\".join((str(test_support.TESTFN), f)) + sf2 = set("\\".join((str(support.TESTFN), f)) for f in f2) self.failUnlessEqual(len(f1), len(self.files)) self.failUnlessEqual(sf2, set(self.files)) @@ -91,7 +91,7 @@ class UnicodeFileTests(unittest.TestCase): os.rename("tmp",name) def test_directory(self): - dirname = os.path.join(test_support.TESTFN,'Gr\xfc\xdf-\u66e8\u66e9\u66eb') + dirname = os.path.join(support.TESTFN,'Gr\xfc\xdf-\u66e8\u66e9\u66eb') filename = '\xdf-\u66e8\u66e9\u66eb' oldwd = os.getcwd() os.mkdir(dirname) @@ -106,9 +106,9 @@ class UnicodeFileTests(unittest.TestCase): def test_main(): try: - test_support.run_unittest(UnicodeFileTests) + support.run_unittest(UnicodeFileTests) finally: - deltree(test_support.TESTFN) + deltree(support.TESTFN) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_pep292.py b/Lib/test/test_pep292.py index 98204901e3..ce9b66363b 100644 --- a/Lib/test/test_pep292.py +++ b/Lib/test/test_pep292.py @@ -185,9 +185,9 @@ class TestTemplate(unittest.TestCase): def test_main(): - from test import test_support + from test import support test_classes = [TestTemplate,] - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) if __name__ == '__main__': diff --git a/Lib/test/test_pep3120.py b/Lib/test/test_pep3120.py index 3f567bf588..3bb30ca761 100644 --- a/Lib/test/test_pep3120.py +++ b/Lib/test/test_pep3120.py @@ -1,7 +1,7 @@ # This file is marked as binary in the CVS, to prevent MacCVS from recoding it. import unittest -from test import test_support +from test import support class PEP3120Test(unittest.TestCase): @@ -24,7 +24,7 @@ class PEP3120Test(unittest.TestCase): self.fail("expected exception didn't occur") def test_main(): - test_support.run_unittest(PEP3120Test) + support.run_unittest(PEP3120Test) if __name__=="__main__": test_main() diff --git a/Lib/test/test_pep3131.py b/Lib/test/test_pep3131.py index 94801c965c..e4c2d031e2 100644 --- a/Lib/test/test_pep3131.py +++ b/Lib/test/test_pep3131.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import unittest -from test import test_support +from test import support class PEP3131Test(unittest.TestCase): @@ -23,7 +23,7 @@ class PEP3131Test(unittest.TestCase): self.fail("expected exception didn't occur") def test_main(): - test_support.run_unittest(PEP3131Test) + support.run_unittest(PEP3131Test) if __name__=="__main__": test_main() diff --git a/Lib/test/test_pep352.py b/Lib/test/test_pep352.py index db117ef2a8..5d75667b68 100644 --- a/Lib/test/test_pep352.py +++ b/Lib/test/test_pep352.py @@ -1,7 +1,7 @@ import unittest import builtins import warnings -from test.test_support import run_unittest +from test.support import run_unittest import os from platform import system as platform_system diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 67d83c7c36..42fb33ee7a 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -1,7 +1,7 @@ import pickle import io -from test import test_support +from test import support from test.pickletester import AbstractPickleTests from test.pickletester import AbstractPickleModuleTests @@ -55,12 +55,12 @@ class PersPicklerTests(AbstractPersistentPicklerTests): return u.load() def test_main(): - test_support.run_unittest( + support.run_unittest( PickleTests, PicklerTests, PersPicklerTests ) - test_support.run_doctest(pickle) + support.run_doctest(pickle) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py index 932dcd19dd..ccb6c9c734 100644 --- a/Lib/test/test_pickletools.py +++ b/Lib/test/test_pickletools.py @@ -1,6 +1,6 @@ import pickle import pickletools -from test import test_support +from test import support from test.pickletester import AbstractPickleTests from test.pickletester import AbstractPickleModuleTests @@ -16,8 +16,8 @@ class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests): error = KeyError def test_main(): - test_support.run_unittest(OptimizedPickleTests) - test_support.run_doctest(pickletools) + support.run_unittest(OptimizedPickleTests) + support.run_doctest(pickletools) if __name__ == "__main__": diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py index 63eaa4daab..d55f3524f6 100644 --- a/Lib/test/test_pipes.py +++ b/Lib/test/test_pipes.py @@ -2,7 +2,7 @@ import pipes import os import string import unittest -from test.test_support import TESTFN, run_unittest, unlink, TestSkipped +from test.support import TESTFN, run_unittest, unlink, TestSkipped if os.name != 'posix': raise TestSkipped('pipes module only works on posix') diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py index db8e844215..1064617f2d 100644 --- a/Lib/test/test_pkg.py +++ b/Lib/test/test_pkg.py @@ -5,7 +5,7 @@ import os import tempfile import textwrap import unittest -from test import test_support +from test import support # Helpers to create and destroy hierarchies. @@ -280,7 +280,7 @@ class TestPkg(unittest.TestCase): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": diff --git a/Lib/test/test_pkgimport.py b/Lib/test/test_pkgimport.py index 316ea832a5..eff7b5a25d 100644 --- a/Lib/test/test_pkgimport.py +++ b/Lib/test/test_pkgimport.py @@ -1,6 +1,6 @@ import os, sys, string, random, tempfile, unittest -from test.test_support import run_unittest +from test.support import run_unittest class TestImport(unittest.TestCase): diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index dfd24301eb..169ef66411 100644 --- a/Lib/test/test_pkgutil.py +++ b/Lib/test/test_pkgutil.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest +from test.support import run_unittest import unittest import sys import imp diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index fced4d0215..3758060b51 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -2,7 +2,7 @@ import sys import unittest import platform -from test import test_support +from test import support class PlatformTest(unittest.TestCase): def test_architecture(self): @@ -82,7 +82,7 @@ class PlatformTest(unittest.TestCase): res = platform.libc_ver(sys.executable) def test_main(): - test_support.run_unittest( + support.run_unittest( PlatformTest ) diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py index 883b01f6cf..b9a46b74a0 100644 --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -4,7 +4,7 @@ import unittest import plistlib import os import datetime -from test import test_support +from test import support # This test data was generated through Cocoa's NSDictionary class @@ -91,7 +91,7 @@ class TestPlistlib(unittest.TestCase): def tearDown(self): try: - os.unlink(test_support.TESTFN) + os.unlink(support.TESTFN) except: pass @@ -123,8 +123,8 @@ class TestPlistlib(unittest.TestCase): def test_io(self): pl = self._create() - plistlib.writePlist(pl, test_support.TESTFN) - pl2 = plistlib.readPlist(test_support.TESTFN) + plistlib.writePlist(pl, support.TESTFN) + pl2 = plistlib.readPlist(support.TESTFN) self.assertEqual(dict(pl), dict(pl2)) def test_bytes(self): @@ -177,7 +177,7 @@ class TestPlistlib(unittest.TestCase): def test_main(): - test_support.run_unittest(TestPlistlib) + support.run_unittest(TestPlistlib) if __name__ == '__main__': diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py index d546c78849..c346ba005f 100644 --- a/Lib/test/test_poll.py +++ b/Lib/test/test_poll.py @@ -1,7 +1,7 @@ # Test case for the os.poll() function import os, select, random, unittest -from test.test_support import TestSkipped, TESTFN, run_unittest +from test.support import TestSkipped, TESTFN, run_unittest try: select.poll diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py index 209bb13148..d72879280c 100644 --- a/Lib/test/test_popen.py +++ b/Lib/test/test_popen.py @@ -5,7 +5,7 @@ """ import unittest -from test import test_support +from test import support import os, sys # Test that command-lines get down as we expect. @@ -40,10 +40,10 @@ class PopenTest(unittest.TestCase): 'foo "a \\"quoted\\" arg" bar', ["foo", 'a "quoted" arg', "bar"] ) - test_support.reap_children() + support.reap_children() def test_main(): - test_support.run_unittest(PopenTest) + support.run_unittest(PopenTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py index cd550df119..14b46e3162 100644 --- a/Lib/test/test_poplib.py +++ b/Lib/test/test_poplib.py @@ -4,9 +4,9 @@ import poplib import time from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST def server(evt, serv): serv.listen(5) @@ -27,7 +27,7 @@ class GeneralTests(TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(3) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) threading.Thread(target=server, args=(self.evt,self.sock)).start() time.sleep(.1) @@ -65,7 +65,7 @@ class GeneralTests(TestCase): def test_main(verbose=None): - test_support.run_unittest(GeneralTests) + support.run_unittest(GeneralTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 57e9d15afe..f16abb2f6e 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -1,11 +1,11 @@ "Test posix functions" -from test import test_support +from test import support try: import posix except ImportError: - raise test_support.TestSkipped("posix is not available") + raise support.TestSkipped("posix is not available") import time import os @@ -19,11 +19,11 @@ class PosixTester(unittest.TestCase): def setUp(self): # create empty file - fp = open(test_support.TESTFN, 'w+') + fp = open(support.TESTFN, 'w+') fp.close() def tearDown(self): - os.unlink(test_support.TESTFN) + os.unlink(support.TESTFN) def testNoArgFunctions(self): # test posix functions which take no arguments and have @@ -46,7 +46,7 @@ class PosixTester(unittest.TestCase): def test_fstatvfs(self): if hasattr(posix, 'fstatvfs'): - fp = open(test_support.TESTFN) + fp = open(support.TESTFN) try: self.assert_(posix.fstatvfs(fp.fileno())) finally: @@ -54,7 +54,7 @@ class PosixTester(unittest.TestCase): def test_ftruncate(self): if hasattr(posix, 'ftruncate'): - fp = open(test_support.TESTFN, 'w+') + fp = open(support.TESTFN, 'w+') try: # we need to have some data to truncate fp.write('test') @@ -65,7 +65,7 @@ class PosixTester(unittest.TestCase): def test_dup(self): if hasattr(posix, 'dup'): - fp = open(test_support.TESTFN) + fp = open(support.TESTFN) try: fd = posix.dup(fp.fileno()) self.assert_(isinstance(fd, int)) @@ -80,8 +80,8 @@ class PosixTester(unittest.TestCase): def test_dup2(self): if hasattr(posix, 'dup2'): - fp1 = open(test_support.TESTFN) - fp2 = open(test_support.TESTFN) + fp1 = open(support.TESTFN) + fp2 = open(support.TESTFN) try: posix.dup2(fp1.fileno(), fp2.fileno()) finally: @@ -89,7 +89,7 @@ class PosixTester(unittest.TestCase): fp2.close() def fdopen_helper(self, *args): - fd = os.open(test_support.TESTFN, os.O_RDONLY) + fd = os.open(support.TESTFN, os.O_RDONLY) fp2 = posix.fdopen(fd, *args) fp2.close() @@ -101,38 +101,38 @@ class PosixTester(unittest.TestCase): def test_osexlock(self): if hasattr(posix, "O_EXLOCK"): - fd = os.open(test_support.TESTFN, + fd = os.open(support.TESTFN, os.O_WRONLY|os.O_EXLOCK|os.O_CREAT) - self.assertRaises(OSError, os.open, test_support.TESTFN, + self.assertRaises(OSError, os.open, support.TESTFN, os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) os.close(fd) if hasattr(posix, "O_SHLOCK"): - fd = os.open(test_support.TESTFN, + fd = os.open(support.TESTFN, os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - self.assertRaises(OSError, os.open, test_support.TESTFN, + self.assertRaises(OSError, os.open, support.TESTFN, os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) os.close(fd) def test_osshlock(self): if hasattr(posix, "O_SHLOCK"): - fd1 = os.open(test_support.TESTFN, + fd1 = os.open(support.TESTFN, os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - fd2 = os.open(test_support.TESTFN, + fd2 = os.open(support.TESTFN, os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) os.close(fd2) os.close(fd1) if hasattr(posix, "O_EXLOCK"): - fd = os.open(test_support.TESTFN, + fd = os.open(support.TESTFN, os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - self.assertRaises(OSError, os.open, test_support.TESTFN, + self.assertRaises(OSError, os.open, support.TESTFN, os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK) os.close(fd) def test_fstat(self): if hasattr(posix, 'fstat'): - fp = open(test_support.TESTFN) + fp = open(support.TESTFN) try: self.assert_(posix.fstat(fp.fileno())) finally: @@ -140,16 +140,16 @@ class PosixTester(unittest.TestCase): def test_stat(self): if hasattr(posix, 'stat'): - self.assert_(posix.stat(test_support.TESTFN)) + self.assert_(posix.stat(support.TESTFN)) if hasattr(posix, 'chown'): def test_chown(self): # raise an OSError if the file does not exist - os.unlink(test_support.TESTFN) - self.assertRaises(OSError, posix.chown, test_support.TESTFN, -1, -1) + os.unlink(support.TESTFN) + self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1) # re-create the file - open(test_support.TESTFN, 'w').close() + open(support.TESTFN, 'w').close() if os.getuid() == 0: try: # Many linux distros have a nfsnobody user as MAX_UID-2 @@ -158,29 +158,29 @@ class PosixTester(unittest.TestCase): # This part of the test only runs when run as root. # Only scary people run their tests as root. ent = pwd.getpwnam('nfsnobody') - posix.chown(test_support.TESTFN, ent.pw_uid, ent.pw_gid) + posix.chown(support.TESTFN, ent.pw_uid, ent.pw_gid) except KeyError: pass else: # non-root cannot chown to root, raises OSError self.assertRaises(OSError, posix.chown, - test_support.TESTFN, 0, 0) + support.TESTFN, 0, 0) # test a successful chown call - posix.chown(test_support.TESTFN, os.getuid(), os.getgid()) + posix.chown(support.TESTFN, os.getuid(), os.getgid()) def test_chdir(self): if hasattr(posix, 'chdir'): posix.chdir(os.curdir) - self.assertRaises(OSError, posix.chdir, test_support.TESTFN) + self.assertRaises(OSError, posix.chdir, support.TESTFN) def test_lsdir(self): if hasattr(posix, 'lsdir'): - self.assert_(test_support.TESTFN in posix.lsdir(os.curdir)) + self.assert_(support.TESTFN in posix.lsdir(os.curdir)) def test_access(self): if hasattr(posix, 'access'): - self.assert_(posix.access(test_support.TESTFN, os.R_OK)) + self.assert_(posix.access(support.TESTFN, os.R_OK)) def test_umask(self): if hasattr(posix, 'umask'): @@ -201,24 +201,24 @@ class PosixTester(unittest.TestCase): def test_utime(self): if hasattr(posix, 'utime'): now = time.time() - posix.utime(test_support.TESTFN, None) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None)) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None)) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now)) - posix.utime(test_support.TESTFN, (int(now), int(now))) - posix.utime(test_support.TESTFN, (now, now)) + posix.utime(support.TESTFN, None) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None)) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None)) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now)) + posix.utime(support.TESTFN, (int(now), int(now))) + posix.utime(support.TESTFN, (now, now)) def test_chflags(self): if hasattr(posix, 'chflags'): - st = os.stat(test_support.TESTFN) + st = os.stat(support.TESTFN) if hasattr(st, 'st_flags'): - posix.chflags(test_support.TESTFN, st.st_flags) + posix.chflags(support.TESTFN, st.st_flags) def test_lchflags(self): if hasattr(posix, 'lchflags'): - st = os.stat(test_support.TESTFN) + st = os.stat(support.TESTFN) if hasattr(st, 'st_flags'): - posix.lchflags(test_support.TESTFN, st.st_flags) + posix.lchflags(support.TESTFN, st.st_flags) def test_environ(self): for k, v in posix.environ.items(): @@ -226,7 +226,7 @@ class PosixTester(unittest.TestCase): self.assertEqual(type(v), str) def test_main(): - test_support.run_unittest(PosixTester) + support.run_unittest(PosixTester) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index a25e2b2159..8a7dd72224 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import posixpath, os from posixpath import realpath, abspath, join, dirname, basename, relpath @@ -7,7 +7,7 @@ from posixpath import realpath, abspath, join, dirname, basename, relpath # An absolute path to a temporary filename for testing. We can't rely on TESTFN # being an absolute path, so we need this. -ABSTFN = abspath(test_support.TESTFN) +ABSTFN = abspath(support.TESTFN) def safe_rmdir(dirname): try: @@ -22,8 +22,8 @@ class PosixPathTest(unittest.TestCase): def tearDown(self): for suffix in ["", "1", "2"]: - test_support.unlink(test_support.TESTFN + suffix) - safe_rmdir(test_support.TESTFN + suffix) + support.unlink(support.TESTFN + suffix) + safe_rmdir(support.TESTFN + suffix) def assertIs(self, a, b): self.assert_(a is b) @@ -141,50 +141,50 @@ class PosixPathTest(unittest.TestCase): self.assertNotEqual(s1[n:n+1], s2[n:n+1]) def test_getsize(self): - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertEqual(posixpath.getsize(test_support.TESTFN), 3) + self.assertEqual(posixpath.getsize(support.TESTFN), 3) finally: if not f.closed: f.close() def test_time(self): - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - f = open(test_support.TESTFN, "ab") + f = open(support.TESTFN, "ab") f.write(b"bar") f.close() - f = open(test_support.TESTFN, "rb") + f = open(support.TESTFN, "rb") d = f.read() f.close() self.assertEqual(d, b"foobar") self.assert_( - posixpath.getctime(test_support.TESTFN) <= - posixpath.getmtime(test_support.TESTFN) + posixpath.getctime(support.TESTFN) <= + posixpath.getmtime(support.TESTFN) ) finally: if not f.closed: f.close() def test_islink(self): - self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False) - f = open(test_support.TESTFN + "1", "wb") + self.assertIs(posixpath.islink(support.TESTFN + "1"), False) + f = open(support.TESTFN + "1", "wb") try: f.write(b"foo") f.close() - self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False) + self.assertIs(posixpath.islink(support.TESTFN + "1"), False) if hasattr(os, "symlink"): - os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2") - self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True) - os.remove(test_support.TESTFN + "1") - self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True) - self.assertIs(posixpath.exists(test_support.TESTFN + "2"), False) - self.assertIs(posixpath.lexists(test_support.TESTFN + "2"), True) + os.symlink(support.TESTFN + "1", support.TESTFN + "2") + self.assertIs(posixpath.islink(support.TESTFN + "2"), True) + os.remove(support.TESTFN + "1") + self.assertIs(posixpath.islink(support.TESTFN + "2"), True) + self.assertIs(posixpath.exists(support.TESTFN + "2"), False) + self.assertIs(posixpath.lexists(support.TESTFN + "2"), True) finally: if not f.close(): f.close() @@ -192,13 +192,13 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.islink) def test_exists(self): - self.assertIs(posixpath.exists(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(posixpath.exists(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(posixpath.exists(test_support.TESTFN), True) - self.assertIs(posixpath.lexists(test_support.TESTFN), True) + self.assertIs(posixpath.exists(support.TESTFN), True) + self.assertIs(posixpath.lexists(support.TESTFN), True) finally: if not f.close(): f.close() @@ -206,16 +206,16 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.exists) def test_isdir(self): - self.assertIs(posixpath.isdir(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(posixpath.isdir(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(posixpath.isdir(test_support.TESTFN), False) - os.remove(test_support.TESTFN) - os.mkdir(test_support.TESTFN) - self.assertIs(posixpath.isdir(test_support.TESTFN), True) - os.rmdir(test_support.TESTFN) + self.assertIs(posixpath.isdir(support.TESTFN), False) + os.remove(support.TESTFN) + os.mkdir(support.TESTFN) + self.assertIs(posixpath.isdir(support.TESTFN), True) + os.rmdir(support.TESTFN) finally: if not f.close(): f.close() @@ -223,16 +223,16 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.isdir) def test_isfile(self): - self.assertIs(posixpath.isfile(test_support.TESTFN), False) - f = open(test_support.TESTFN, "wb") + self.assertIs(posixpath.isfile(support.TESTFN), False) + f = open(support.TESTFN, "wb") try: f.write(b"foo") f.close() - self.assertIs(posixpath.isfile(test_support.TESTFN), True) - os.remove(test_support.TESTFN) - os.mkdir(test_support.TESTFN) - self.assertIs(posixpath.isfile(test_support.TESTFN), False) - os.rmdir(test_support.TESTFN) + self.assertIs(posixpath.isfile(support.TESTFN), True) + os.remove(support.TESTFN) + os.mkdir(support.TESTFN) + self.assertIs(posixpath.isfile(support.TESTFN), False) + os.rmdir(support.TESTFN) finally: if not f.close(): f.close() @@ -240,14 +240,14 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.isdir) def test_samefile(self): - f = open(test_support.TESTFN + "1", "wb") + f = open(support.TESTFN + "1", "wb") try: f.write(b"foo") f.close() self.assertIs( posixpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "1" + support.TESTFN + "1", + support.TESTFN + "1" ), True ) @@ -255,24 +255,24 @@ class PosixPathTest(unittest.TestCase): # inode information and thus, that samefile() doesn't work if hasattr(os, "symlink"): os.symlink( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ) self.assertIs( posixpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ), True ) - os.remove(test_support.TESTFN + "2") - f = open(test_support.TESTFN + "2", "wb") + os.remove(support.TESTFN + "2") + f = open(support.TESTFN + "2", "wb") f.write(b"bar") f.close() self.assertIs( posixpath.samefile( - test_support.TESTFN + "1", - test_support.TESTFN + "2" + support.TESTFN + "1", + support.TESTFN + "2" ), False ) @@ -283,14 +283,14 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.samefile) def test_samestat(self): - f = open(test_support.TESTFN + "1", "wb") + f = open(support.TESTFN + "1", "wb") try: f.write(b"foo") f.close() self.assertIs( posixpath.samestat( - os.stat(test_support.TESTFN + "1"), - os.stat(test_support.TESTFN + "1") + os.stat(support.TESTFN + "1"), + os.stat(support.TESTFN + "1") ), True ) @@ -298,22 +298,22 @@ class PosixPathTest(unittest.TestCase): # inode information and thus, that samefile() doesn't work if hasattr(os, "symlink"): if hasattr(os, "symlink"): - os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2") + os.symlink(support.TESTFN + "1", support.TESTFN + "2") self.assertIs( posixpath.samestat( - os.stat(test_support.TESTFN + "1"), - os.stat(test_support.TESTFN + "2") + os.stat(support.TESTFN + "1"), + os.stat(support.TESTFN + "2") ), True ) - os.remove(test_support.TESTFN + "2") - f = open(test_support.TESTFN + "2", "wb") + os.remove(support.TESTFN + "2") + f = open(support.TESTFN + "2", "wb") f.write(b"bar") f.close() self.assertIs( posixpath.samestat( - os.stat(test_support.TESTFN + "1"), - os.stat(test_support.TESTFN + "2") + os.stat(support.TESTFN + "1"), + os.stat(support.TESTFN + "2") ), False ) @@ -399,7 +399,7 @@ class PosixPathTest(unittest.TestCase): os.symlink(ABSTFN+"1", ABSTFN) self.assertEqual(realpath(ABSTFN), ABSTFN+"1") finally: - test_support.unlink(ABSTFN) + support.unlink(ABSTFN) def test_realpath_symlink_loops(self): # Bug #930024, return the path unchanged if we get into an infinite @@ -419,9 +419,9 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath(basename(ABSTFN)), ABSTFN) finally: os.chdir(old_path) - test_support.unlink(ABSTFN) - test_support.unlink(ABSTFN+"1") - test_support.unlink(ABSTFN+"2") + support.unlink(ABSTFN) + support.unlink(ABSTFN+"1") + support.unlink(ABSTFN+"2") def test_realpath_resolve_parents(self): # We also need to resolve any symlinks in the parents of a relative @@ -438,7 +438,7 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath("a"), ABSTFN + "/y/a") finally: os.chdir(old_path) - test_support.unlink(ABSTFN + "/k") + support.unlink(ABSTFN + "/k") safe_rmdir(ABSTFN + "/y") safe_rmdir(ABSTFN) @@ -464,7 +464,7 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."), ABSTFN + "/k") finally: os.chdir(old_path) - test_support.unlink(ABSTFN + "/link-y") + support.unlink(ABSTFN + "/link-y") safe_rmdir(ABSTFN + "/k/y") safe_rmdir(ABSTFN + "/k") safe_rmdir(ABSTFN) @@ -485,7 +485,7 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k") finally: os.chdir(old_path) - test_support.unlink(ABSTFN + "link") + support.unlink(ABSTFN + "link") safe_rmdir(ABSTFN + "/k") safe_rmdir(ABSTFN) @@ -506,7 +506,7 @@ class PosixPathTest(unittest.TestCase): os.getcwd = real_getcwd def test_main(): - test_support.run_unittest(PosixPathTest) + support.run_unittest(PosixPathTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py index 9b358f1970..859c3737b9 100644 --- a/Lib/test/test_pow.py +++ b/Lib/test/test_pow.py @@ -1,4 +1,4 @@ -import test.test_support, unittest +import test.support, unittest class PowTest(unittest.TestCase): @@ -123,7 +123,7 @@ class PowTest(unittest.TestCase): eq(expected, 1.0) # else we didn't push fiveto to evenness def test_main(): - test.test_support.run_unittest(PowTest) + test.support.run_unittest(PowTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py index ed352877f5..54c0c57606 100644 --- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -1,5 +1,5 @@ import pprint -import test.test_support +import test.support import unittest import test.test_set @@ -411,7 +411,7 @@ class DottedPrettyPrinter(pprint.PrettyPrinter): def test_main(): - test.test_support.run_unittest(QueryTestCase) + test.support.run_unittest(QueryTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_print.py b/Lib/test/test_print.py index 58ca06988a..f157bc7db6 100644 --- a/Lib/test/test_print.py +++ b/Lib/test/test_print.py @@ -6,7 +6,7 @@ from __future__ import print_function import unittest -from test import test_support +from test import support import sys try: @@ -62,7 +62,7 @@ class TestPrint(unittest.TestCase): end is not NotDefined, file is not NotDefined)] - with test_support.captured_stdout() as t: + with support.captured_stdout() as t: fn(args, sep, end, file) self.assertEqual(t.getvalue(), expected) @@ -113,7 +113,7 @@ class TestPrint(unittest.TestCase): self.assertRaises(AttributeError, print, '', file='') def test_main(): - test_support.run_unittest(TestPrint) + support.run_unittest(TestPrint) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py index 9fea434d86..84167ddc21 100755 --- a/Lib/test/test_profile.py +++ b/Lib/test/test_profile.py @@ -6,7 +6,7 @@ import pstats import unittest from difflib import unified_diff from io import StringIO -from test.test_support import run_unittest +from test.support import run_unittest import profile from test.profilee import testfunc, timer diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_profilehooks.py index 6d6aa8e594..296c997c53 100644 --- a/Lib/test/test_profilehooks.py +++ b/Lib/test/test_profilehooks.py @@ -2,7 +2,7 @@ import pprint import sys import unittest -from test import test_support +from test import support class TestGetProfile(unittest.TestCase): def setUp(self): @@ -357,7 +357,7 @@ def capture_events(callable, p=None): except TypeError: pass else: - raise test_support.TestFailed( + raise support.TestFailed( 'sys.setprofile() did not raise TypeError') if p is None: @@ -374,7 +374,7 @@ def show_events(callable): def test_main(): - test_support.run_unittest( + support.run_unittest( TestGetProfile, ProfileHookTestCase, ProfileSimulatorTestCase diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index 4b6e20caa3..c957ec272c 100644 --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -2,7 +2,7 @@ # more tests are in test_descr import unittest -from test.test_support import run_unittest +from test.support import run_unittest class PropertyBase(Exception): pass diff --git a/Lib/test/test_pstats.py b/Lib/test/test_pstats.py index 660316b19f..095123d881 100644 --- a/Lib/test/test_pstats.py +++ b/Lib/test/test_pstats.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import pstats @@ -17,7 +17,7 @@ class AddCallersTestCase(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( AddCallersTestCase ) diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index 58a304186f..f62fc99fba 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -4,7 +4,7 @@ import pty import os import sys import signal -from test.test_support import verbose, TestSkipped, run_unittest +from test.support import verbose, TestSkipped, run_unittest import unittest TEST_STRING_1 = "I wish to buy a fish license.\n" diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py index 19187a3d74..b5a5de79d7 100644 --- a/Lib/test/test_pwd.py +++ b/Lib/test/test_pwd.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import pwd @@ -91,7 +91,7 @@ class PwdTest(unittest.TestCase): self.assertRaises(KeyError, pwd.getpwuid, fakeuid) def test_main(): - test_support.run_unittest(PwdTest) + support.run_unittest(PwdTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py index 57ede89652..bcc16df16d 100644 --- a/Lib/test/test_pyclbr.py +++ b/Lib/test/test_pyclbr.py @@ -2,7 +2,7 @@ Test cases for pyclbr.py Nick Mathewson ''' -from test.test_support import run_unittest +from test.support import run_unittest import sys from types import FunctionType, MethodType, BuiltinFunctionType import pyclbr diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index ba37ec12fe..cc4a096f00 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -1,4 +1,4 @@ -from test import test_support
+from test import support
import unittest
import pydoc
@@ -19,7 +19,7 @@ class TestDescriptions(unittest.TestCase): in pydoc.render_doc(c))
def test_main():
- test_support.run_unittest(TestDescriptions)
+ support.run_unittest(TestDescriptions)
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 9fda72d18f..c252134b02 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -8,7 +8,7 @@ import unittest import pyexpat from xml.parsers import expat -from test.test_support import sortdict, run_unittest +from test.support import sortdict, run_unittest class SetAttributeTest(unittest.TestCase): diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py index df7b7e3421..6303117261 100644 --- a/Lib/test/test_queue.py +++ b/Lib/test/test_queue.py @@ -5,7 +5,7 @@ import sys import threading import time import unittest -from test import test_support +from test import support QUEUE_SIZE = 5 @@ -318,7 +318,7 @@ class FailingQueueTest(unittest.TestCase, BlockingTestMixin): def test_main(): - test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, + support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest, FailingQueueTest) diff --git a/Lib/test/test_quopri.py b/Lib/test/test_quopri.py index b9ad65be28..2c52a3c025 100644 --- a/Lib/test/test_quopri.py +++ b/Lib/test/test_quopri.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import sys, os, io, subprocess @@ -199,7 +199,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''') self.assertEqual(cout.splitlines(), p.splitlines()) def test_main(): - test_support.run_unittest(QuopriTestCase) + support.run_unittest(QuopriTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_raise.py b/Lib/test/test_raise.py index 27a5cbcf65..89e219048b 100644 --- a/Lib/test/test_raise.py +++ b/Lib/test/test_raise.py @@ -3,7 +3,7 @@ """Tests for the raise statement.""" -from test import test_support +from test import support import sys import types import unittest @@ -156,7 +156,7 @@ class TestRemovedFunctionality(unittest.TestCase): def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index c02eb09267..04c49fa670 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -6,7 +6,7 @@ import time import pickle import warnings from math import log, exp, sqrt, pi -from test import test_support +from test import support class TestBasicOps(unittest.TestCase): # Superclass with tests common to all generators. @@ -118,7 +118,7 @@ class TestBasicOps(unittest.TestCase): ("randv2_64.pck", 866), ("randv3.pck", 343)] for file, value in files: - f = open(test_support.findfile(file),"rb") + f = open(support.findfile(file),"rb") r = pickle.load(f) f.close() self.assertEqual(r.randrange(1000), value) @@ -474,14 +474,14 @@ def test_main(verbose=None): else: testclasses.append(SystemRandom_TestBasicOps) - test_support.run_unittest(*testclasses) + support.run_unittest(*testclasses) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*testclasses) + support.run_unittest(*testclasses) counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py index dedf007282..1fd8f1d141 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -1,6 +1,6 @@ # Python test set -- built-in functions -import test.test_support, unittest +import test.support, unittest import sys import warnings @@ -62,7 +62,7 @@ class RangeTest(unittest.TestCase): self.assertEqual(repr(range(1, 2, 3)), 'range(1, 2, 3)') def test_main(): - test.test_support.run_unittest(RangeTest) + test.support.run_unittest(RangeTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 11677f35f5..0b023c2fb7 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1,7 +1,7 @@ import sys sys.path = ['.'] + sys.path -from test.test_support import verbose, run_unittest, catch_warning +from test.support import verbose, run_unittest, catch_warning import re from re import Scanner import sys, os, traceback diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py index 442c0482c7..8bd0ccf911 100644 --- a/Lib/test/test_reprlib.py +++ b/Lib/test/test_reprlib.py @@ -8,7 +8,7 @@ import os import shutil import unittest -from test.test_support import run_unittest +from test.support import run_unittest from reprlib import repr as r # Don't shadow builtin repr from reprlib import Repr diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index b66caf81a3..7063ff9c2a 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import resource import time @@ -47,7 +47,7 @@ class ResourceTest(unittest.TestCase): limit_set = True except ValueError: limit_set = False - f = open(test_support.TESTFN, "wb") + f = open(support.TESTFN, "wb") try: f.write(b"X" * 1024) try: @@ -73,7 +73,7 @@ class ResourceTest(unittest.TestCase): finally: if limit_set: resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_fsize_toobig(self): # Be sure that setrlimit is checking for really large values @@ -104,7 +104,7 @@ class ResourceTest(unittest.TestCase): pass def test_main(verbose=None): - test_support.run_unittest(ResourceTest) + support.run_unittest(ResourceTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py index 1f5dd64190..d2883e96d3 100644 --- a/Lib/test/test_rfc822.py +++ b/Lib/test/test_rfc822.py @@ -1,6 +1,6 @@ import rfc822 import unittest -from test import test_support +from test import support try: from io import StringIO @@ -249,7 +249,7 @@ A test message. def test_main(): - test_support.run_unittest(MessageTestCase) + support.run_unittest(MessageTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py index 7b6f9be254..30dac8f917 100644 --- a/Lib/test/test_richcmp.py +++ b/Lib/test/test_richcmp.py @@ -1,7 +1,7 @@ # Tests for rich comparisons import unittest -from test import test_support +from test import support import operator @@ -29,7 +29,7 @@ class Number: return self.x >= other def __cmp__(self, other): - raise test_support.TestFailed("Number.__cmp__() should not be called") + raise support.TestFailed("Number.__cmp__() should not be called") def __repr__(self): return "Number(%r)" % (self.x, ) @@ -55,7 +55,7 @@ class Vector: raise TypeError("Vectors cannot be used in Boolean contexts") def __cmp__(self, other): - raise test_support.TestFailed("Vector.__cmp__() should not be called") + raise support.TestFailed("Vector.__cmp__() should not be called") def __repr__(self): return "Vector(%r)" % (self.data, ) @@ -387,11 +387,11 @@ class HashableTest(unittest.TestCase): self.assertEquals(str(e), "unhashable type: 'DumbEqualityWithoutHash'") else: - raise test_support.TestFailed("Should not be here") + raise support.TestFailed("Should not be here") def test_main(): - test_support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest, HashableTest) + support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest, HashableTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py index ad66b69490..4e530f0d3d 100644 --- a/Lib/test/test_robotparser.py +++ b/Lib/test/test_robotparser.py @@ -1,6 +1,6 @@ import unittest, robotparser import io -from test import test_support +from test import support class RobotTestCase(unittest.TestCase): def __init__(self, index, parser, url, good, agent): @@ -137,7 +137,7 @@ RobotTest(7, doc, good, bad) class TestCase(unittest.TestCase): def runTest(self): - test_support.requires('network') + support.requires('network') # whole site is password-protected. url = 'http://mueblesmoraleda.com' parser = robotparser.RobotFileParser() @@ -146,9 +146,9 @@ class TestCase(unittest.TestCase): self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False) def test_main(): - test_support.run_unittest(tests) + support.run_unittest(tests) TestCase().run() if __name__=='__main__': - test_support.Verbose = 1 + support.Verbose = 1 test_main() diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py index ffa36dc75b..43691cbbb6 100644 --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -4,7 +4,7 @@ import os import os.path import sys import tempfile -from test.test_support import verbose, run_unittest, forget +from test.support import verbose, run_unittest, forget from runpy import _run_code, _run_module_code, run_module # Note: This module can't safely test _run_module_as_main as it diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index eb795813ae..5f1a48ed48 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -13,7 +13,7 @@ from xml.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \ from xml.sax.expatreader import create_parser from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl from io import StringIO -from test.test_support import findfile, run_unittest +from test.support import findfile, run_unittest import unittest import os diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index c18445df50..a3f1d4a50d 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -1,5 +1,5 @@ import unittest -from test.test_support import check_syntax_error, run_unittest +from test.support import check_syntax_error, run_unittest import warnings warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<test string>") diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py index f4032d1c0c..a463868f62 100644 --- a/Lib/test/test_select.py +++ b/Lib/test/test_select.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import select import os @@ -21,23 +21,23 @@ class SelectTestCase(unittest.TestCase): def test_select(self): if sys.platform[:3] in ('win', 'mac', 'os2', 'riscos'): - if test_support.verbose: + if support.verbose: print("Can't test select easily on", sys.platform) return cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' p = os.popen(cmd, 'r') for tout in (0, 1, 2, 4, 8, 16) + (None,)*10: - if test_support.verbose: + if support.verbose: print('timeout =', tout) rfd, wfd, xfd = select.select([p], [], [], tout) if (rfd, wfd, xfd) == ([], [], []): continue if (rfd, wfd, xfd) == ([p], [], []): line = p.readline() - if test_support.verbose: + if support.verbose: print(repr(line)) if not line: - if test_support.verbose: + if support.verbose: print('EOF') break continue @@ -45,8 +45,8 @@ class SelectTestCase(unittest.TestCase): p.close() def test_main(): - test_support.run_unittest(SelectTestCase) - test_support.reap_children() + support.run_unittest(SelectTestCase) + support.reap_children() if __name__ == "__main__": test_main() diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index 44a45afa60..d05df3f24d 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support from weakref import proxy import operator import copy @@ -288,14 +288,14 @@ class TestJointOps(unittest.TestCase): s = self.thetype([w]) w.value = s try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") fo.write(str(s)) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(s)) finally: fo.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_do_not_rehash_dict_keys(self): n = 10 @@ -672,14 +672,14 @@ class TestBasicOps(unittest.TestCase): def test_print(self): try: - fo = open(test_support.TESTFN, "w") + fo = open(support.TESTFN, "w") fo.write(str(self.set)) fo.close() - fo = open(test_support.TESTFN, "r") + fo = open(support.TESTFN, "r") self.assertEqual(fo.read(), repr(self.set)) finally: fo.close() - test_support.unlink(test_support.TESTFN) + support.unlink(support.TESTFN) def test_length(self): self.assertEqual(len(self.set), self.length) @@ -1752,14 +1752,14 @@ def test_main(verbose=None): TestGraphs, ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_setcomps.py b/Lib/test/test_setcomps.py index f382293028..fb7cde03d7 100644 --- a/Lib/test/test_setcomps.py +++ b/Lib/test/test_setcomps.py @@ -133,16 +133,16 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys - from test import test_support + from test import support from test import test_setcomps - test_support.run_doctest(test_setcomps, verbose) + support.run_doctest(test_setcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_setcomps, verbose) + support.run_doctest(test_setcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_sgmllib.py b/Lib/test/test_sgmllib.py index 374b921300..60158785f3 100644 --- a/Lib/test/test_sgmllib.py +++ b/Lib/test/test_sgmllib.py @@ -2,7 +2,7 @@ import pprint import re import sgmllib import unittest -from test import test_support +from test import support class EventCollector(sgmllib.SGMLParser): @@ -365,7 +365,7 @@ DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' # Just verify this code doesn't cause a hang. CHUNK = 1024 # increasing this to 8212 makes the problem go away - f = open(test_support.findfile('sgml_input.html'), encoding="latin-1") + f = open(support.findfile('sgml_input.html'), encoding="latin-1") fp = sgmllib.SGMLParser() while 1: data = f.read(CHUNK) @@ -431,7 +431,7 @@ DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' def test_main(): - test_support.run_unittest(SGMLParserTestCase) + support.run_unittest(SGMLParserTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_shelve.py b/Lib/test/test_shelve.py index 6d917ff522..5fb4641e7c 100644 --- a/Lib/test/test_shelve.py +++ b/Lib/test/test_shelve.py @@ -1,7 +1,7 @@ import unittest import shelve import glob -from test import test_support +from test import support from collections import MutableMapping from test.test_anydbm import dbm_iterator @@ -45,7 +45,7 @@ class TestCase(unittest.TestCase): def tearDown(self): for f in glob.glob(self.fn+"*"): - test_support.unlink(f) + support.unlink(f) def test_ascii_file_shelf(self): s = shelve.open(self.fn, protocol=0) @@ -133,7 +133,7 @@ class TestShelveBase(mapping_tests.BasicTestMappingProtocol): self._db = [] if not self._in_mem: for f in glob.glob(self.fn+"*"): - test_support.unlink(f) + support.unlink(f) class TestAsciiFileShelve(TestShelveBase): _args={'protocol':0} @@ -156,7 +156,7 @@ class TestProto2MemShelve(TestShelveBase): def test_main(): for module in dbm_iterator(): - test_support.run_unittest( + support.run_unittest( TestAsciiFileShelve, TestBinaryFileShelve, TestProto2FileShelve, diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py index b18155e165..1685938d79 100644 --- a/Lib/test/test_shlex.py +++ b/Lib/test/test_shlex.py @@ -3,7 +3,7 @@ import unittest import os, sys, io import shlex -from test import test_support +from test import support # The original test data set was from shellwords, by Hartmut Goebel. @@ -181,7 +181,7 @@ if not getattr(shlex, "split", None): delattr(ShlexTest, methname) def test_main(): - test_support.run_unittest(ShlexTest) + support.run_unittest(ShlexTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 2a316b2d5a..2e680a90d3 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -7,8 +7,8 @@ import sys import stat import os import os.path -from test import test_support -from test.test_support import TESTFN +from test import support +from test.support import TESTFN class TestShutil(unittest.TestCase): def test_rmtree_errors(self): @@ -267,7 +267,7 @@ class TestMove(unittest.TestCase): def test_main(): - test_support.run_unittest(TestShutil, TestMove) + support.run_unittest(TestShutil, TestMove) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index 339cec216e..b8ac2ccc11 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support from contextlib import closing, nested import gc import pickle @@ -10,7 +10,7 @@ import traceback import sys, os, time, errno if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos': - raise test_support.TestSkipped("Can't test signal on %s" % \ + raise support.TestSkipped("Can't test signal on %s" % \ sys.platform) @@ -53,13 +53,13 @@ class InterProcessSignalTests(unittest.TestCase): def handlerA(self, signum, frame): self.a_called = True - if test_support.verbose: + if support.verbose: print("handlerA invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1))) def handlerB(self, signum, frame): self.b_called = True - if test_support.verbose: + if support.verbose: print ("handlerB invoked from signal %s at:\n%s" % ( signum, self.format_frame(frame, limit=1))) raise HandlerBCalled(signum, self.format_frame(frame)) @@ -88,7 +88,7 @@ class InterProcessSignalTests(unittest.TestCase): # Let the sub-processes know who to send signals to. pid = os.getpid() - if test_support.verbose: + if support.verbose: print("test runner's pid is", pid) child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)]) @@ -113,7 +113,7 @@ class InterProcessSignalTests(unittest.TestCase): except HandlerBCalled: self.assertTrue(self.b_called) self.assertFalse(self.a_called) - if test_support.verbose: + if support.verbose: print("HandlerBCalled exception caught") child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)]) @@ -130,7 +130,7 @@ class InterProcessSignalTests(unittest.TestCase): # may return early. time.sleep(1) except KeyboardInterrupt: - if test_support.verbose: + if support.verbose: print("KeyboardInterrupt (the alarm() went off)") except: self.fail("Some other exception woke us from pause: %s" % @@ -309,7 +309,7 @@ class ItimerTest(unittest.TestCase): def sig_alrm(self, *args): self.hndl_called = True - if test_support.verbose: + if support.verbose: print("SIGALRM handler invoked", args) def sig_vtalrm(self, *args): @@ -322,19 +322,19 @@ class ItimerTest(unittest.TestCase): elif self.hndl_count == 3: # disable ITIMER_VIRTUAL, this function shouldn't be called anymore signal.setitimer(signal.ITIMER_VIRTUAL, 0) - if test_support.verbose: + if support.verbose: print("last SIGVTALRM handler call") self.hndl_count += 1 - if test_support.verbose: + if support.verbose: print("SIGVTALRM handler invoked", args) def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) - if test_support.verbose: + if support.verbose: print("SIGPROF handler invoked", args) def test_itimer_exc(self): @@ -349,7 +349,7 @@ class ItimerTest(unittest.TestCase): def test_itimer_real(self): self.itimer = signal.ITIMER_REAL signal.setitimer(self.itimer, 1.0) - if test_support.verbose: + if support.verbose: print("\ncall pause()...") signal.pause() @@ -384,7 +384,7 @@ class ItimerTest(unittest.TestCase): self.assertEqual(self.hndl_called, True) def test_main(): - test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, + support.run_unittest(BasicSignalTests, InterProcessSignalTests, WakeupSignalTests, SiginterruptTest, ItimerTest) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index a13751c56f..3f93a38fa4 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -5,7 +5,7 @@ executing have not been removed. """ import unittest -from test.test_support import TestSkipped, run_unittest, TESTFN +from test.support import TestSkipped, run_unittest, TESTFN import builtins import os import sys diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py index 20d2027028..e61974658c 100644 --- a/Lib/test/test_slice.py +++ b/Lib/test/test_slice.py @@ -1,7 +1,7 @@ # tests for slice objects; in particular the indices method. import unittest -from test import test_support +from test import support from pickle import loads, dumps import sys @@ -115,7 +115,7 @@ class SliceTest(unittest.TestCase): self.assertNotEqual(id(s), id(t)) def test_main(): - test_support.run_unittest(SliceTest) + support.run_unittest(SliceTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 9dc672d5ac..3d38d89d27 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -10,9 +10,9 @@ import time import select from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST def server(evt, buf, serv): serv.listen(5) @@ -42,7 +42,7 @@ class GeneralTests(TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) servargs = (self.evt, b"220 Hola mundo\n", self.sock) threading.Thread(target=server, args=servargs).start() self.evt.wait() @@ -142,7 +142,7 @@ class DebuggingServerTests(TestCase): self.serv_evt = threading.Event() self.client_evt = threading.Event() - self.port = test_support.find_unused_port() + self.port = support.find_unused_port() self.serv = smtpd.DebuggingServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) threading.Thread(target=debugging_server, args=serv_args).start() @@ -250,7 +250,7 @@ class BadHELOServerTests(TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) servargs = (self.evt, b"199 no hello for you!\n", self.sock) threading.Thread(target=server, args=servargs).start() self.evt.wait() @@ -327,7 +327,7 @@ class SMTPSimTests(TestCase): def setUp(self): self.serv_evt = threading.Event() self.client_evt = threading.Event() - self.port = test_support.find_unused_port() + self.port = support.find_unused_port() self.serv = SimSMTPServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) threading.Thread(target=debugging_server, args=serv_args).start() @@ -401,7 +401,7 @@ class SMTPSimTests(TestCase): def test_main(verbose=None): - test_support.run_unittest(GeneralTests, DebuggingServerTests, + support.run_unittest(GeneralTests, DebuggingServerTests, NonConnectingTests, BadHELOServerTests, SMTPSimTests) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index ab860ddf80..349548f717 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import unittest -from test import test_support +from test import support import errno import socket @@ -16,14 +16,14 @@ import array from weakref import proxy import signal -HOST = test_support.HOST +HOST = support.HOST MSG = b'Michael Gilfix was here\n' class SocketTCPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.port = test_support.bind_port(self.serv) + self.port = support.bind_port(self.serv) self.serv.listen(1) def tearDown(self): @@ -34,7 +34,7 @@ class SocketUDPTest(unittest.TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.port = test_support.bind_port(self.serv) + self.port = support.bind_port(self.serv) def tearDown(self): self.serv.close() @@ -898,7 +898,7 @@ class BasicTCPTest2(NetworkConnectionTest, BasicTCPTest): class NetworkConnectionNoServer(unittest.TestCase): def testWithoutServer(self): - port = test_support.find_unused_port() + port = support.find_unused_port() self.failUnlessRaises( socket.error, lambda: socket.create_connection((HOST, port)) @@ -1145,7 +1145,7 @@ def isTipcAvailable(): for line in f: if line.startswith("tipc "): return True - if test_support.verbose: + if support.verbose: print("TIPC module is not loaded, please 'sudo modprobe tipc'") return False @@ -1229,9 +1229,9 @@ def test_main(): tests.append(TIPCTest) tests.append(TIPCThreadableTest) - thread_info = test_support.threading_setup() - test_support.run_unittest(*tests) - test_support.threading_cleanup(*thread_info) + thread_info = support.threading_setup() + support.run_unittest(*tests) + support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index b6bb0f70ec..5b733ae401 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -15,14 +15,14 @@ import time import unittest import socketserver -import test.test_support -from test.test_support import reap_children, verbose, TestSkipped -from test.test_support import TESTFN as TEST_FILE +import test.support +from test.support import reap_children, verbose, TestSkipped +from test.support import TESTFN as TEST_FILE -test.test_support.requires("network") +test.support.requires("network") TEST_STR = b"hello world\n" -HOST = test.test_support.HOST +HOST = test.support.HOST HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" @@ -249,7 +249,7 @@ def test_main(): # If the import lock is held, the threads will hang raise TestSkipped("can't run when import lock is held") - test.test_support.run_unittest(SocketServerTest) + test.support.run_unittest(SocketServerTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py index 8301c319e9..8b108d59a3 100644 --- a/Lib/test/test_sort.py +++ b/Lib/test/test_sort.py @@ -1,9 +1,9 @@ -from test import test_support +from test import support import random import sys import unittest -verbose = test_support.verbose +verbose = support.verbose nerrors = 0 def CmpToKey(mycmp): @@ -261,14 +261,14 @@ def test_main(verbose=None): TestBugs, ) - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_sqlite.py b/Lib/test/test_sqlite.py index 945dd511b8..b8a9acff78 100644 --- a/Lib/test/test_sqlite.py +++ b/Lib/test/test_sqlite.py @@ -1,4 +1,4 @@ -from test.test_support import run_unittest, TestSkipped +from test.support import run_unittest, TestSkipped try: import _sqlite3 diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 59bf57dd4d..4f884f0381 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -2,7 +2,7 @@ import sys import unittest -from test import test_support +from test import support import socket import select import errno @@ -25,27 +25,27 @@ try: except ImportError: skip_expected = True -HOST = test_support.HOST +HOST = support.HOST CERTFILE = None SVN_PYTHON_ORG_ROOT_CERT = None def handle_error(prefix): exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) - if test_support.verbose: + if support.verbose: sys.stdout.write(prefix + exc_format) class BasicTests(unittest.TestCase): def testSSLconnect(self): - if not test_support.is_resource_enabled('network'): + if not support.is_resource_enabled('network'): return s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: - raise test_support.TestFailed("Peer cert %s shouldn't be here!") + raise support.TestFailed("Peer cert %s shouldn't be here!") s.close() # this should fail because we have no verification certs @@ -69,7 +69,7 @@ class BasicTests(unittest.TestCase): def testRAND(self): v = ssl.RAND_status() - if test_support.verbose: + if support.verbose: sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) @@ -86,7 +86,7 @@ class BasicTests(unittest.TestCase): # provided solely for this test, to exercise the certificate # parsing code p = ssl._ssl._test_decode_cert(CERTFILE, False) - if test_support.verbose: + if support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") def testDERtoPEM(self): @@ -96,7 +96,7 @@ class BasicTests(unittest.TestCase): p2 = ssl.DER_cert_to_PEM_cert(d1) d2 = ssl.PEM_cert_to_DER_cert(p2) if (d1 != d2): - raise test_support.TestFailed("PEM-to-DER or DER-to-PEM translation failed") + raise support.TestFailed("PEM-to-DER or DER-to-PEM translation failed") class NetworkedTests(unittest.TestCase): @@ -106,7 +106,7 @@ class NetworkedTests(unittest.TestCase): s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: - raise test_support.TestFailed("Peer cert %s shouldn't be here!") + raise support.TestFailed("Peer cert %s shouldn't be here!") s.close() # this should fail because we have no verification certs @@ -126,7 +126,7 @@ class NetworkedTests(unittest.TestCase): try: s.connect(("svn.python.org", 443)) except ssl.SSLError as x: - raise test_support.TestFailed("Unexpected exception %s" % x) + raise support.TestFailed("Unexpected exception %s" % x) finally: s.close() @@ -151,14 +151,14 @@ class NetworkedTests(unittest.TestCase): else: raise s.close() - if test_support.verbose: + if support.verbose: sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count) def testFetchServerCert(self): pem = ssl.get_server_certificate(("svn.python.org", 443)) if not pem: - raise test_support.TestFailed("No server certificate on svn.python.org:443!") + raise support.TestFailed("No server certificate on svn.python.org:443!") return @@ -166,15 +166,15 @@ class NetworkedTests(unittest.TestCase): pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=CERTFILE) except ssl.SSLError as x: #should fail - if test_support.verbose: + if support.verbose: sys.stdout.write("%s\n" % x) else: - raise test_support.TestFailed("Got server certificate %s for svn.python.org!" % pem) + raise support.TestFailed("Got server certificate %s for svn.python.org!" % pem) pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=SVN_PYTHON_ORG_ROOT_CERT) if not pem: - raise test_support.TestFailed("No server certificate on svn.python.org:443!") - if test_support.verbose: + raise support.TestFailed("No server certificate on svn.python.org:443!") + if support.verbose: sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem) @@ -227,13 +227,13 @@ else: else: if self.server.certreqs == ssl.CERT_REQUIRED: cert = self.sslconn.getpeercert() - if test_support.verbose and self.server.chatty: + if support.verbose and self.server.chatty: sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n") cert_binary = self.sslconn.getpeercert(True) - if test_support.verbose and self.server.chatty: + if support.verbose and self.server.chatty: sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n") cipher = self.sslconn.cipher() - if test_support.verbose and self.server.chatty: + if support.verbose and self.server.chatty: sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n") return True @@ -269,19 +269,19 @@ else: self.running = False self.close() elif amsg.strip() == 'over': - if test_support.verbose and self.server.connectionchatty: + if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: client closed connection\n") self.close() return elif (self.server.starttls_server and amsg.strip() == 'STARTTLS'): - if test_support.verbose and self.server.connectionchatty: + if support.verbose and self.server.connectionchatty: sys.stdout.write(" server: read STARTTLS from client, sending OK...\n") self.write("OK\n".encode("ASCII", "strict")) if not self.wrap_conn(): return else: - if (test_support.verbose and + if (support.verbose and self.server.connectionchatty): ctype = (self.sslconn and "encrypted") or "unencrypted" sys.stdout.write(" server: read %s (%s), sending back %s (%s)...\n" @@ -314,7 +314,7 @@ else: self.connectionchatty = connectionchatty self.starttls_server = starttls_server self.sock = socket.socket() - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) self.flag = None self.active = False threading.Thread.__init__(self) @@ -334,7 +334,7 @@ else: while self.active: try: newconn, connaddr = self.sock.accept() - if test_support.verbose and self.chatty: + if support.verbose and self.chatty: sys.stdout.write(' server: new connection from ' + repr(connaddr) + '\n') handler = self.ConnectionHandler(self, newconn, connaddr) @@ -457,7 +457,7 @@ else: # we override this to suppress logging unless "verbose" - if test_support.verbose: + if support.verbose: sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" % (self.server.server_address, self.server.server_port, @@ -470,7 +470,7 @@ else: self.flag = None self.active = False self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0] - self.port = test_support.find_unused_port() + self.port = support.find_unused_port() self.server = self.HTTPSServer( (HOST, self.port), self.RootedHTTPRequestHandler, certfile) threading.Thread.__init__(self) @@ -522,7 +522,7 @@ else: def handle_read(self): data = self.recv(1024) - if test_support.verbose: + if support.verbose: sys.stdout.write(" server: read %s from client\n" % repr(data)) if not data: self.close() @@ -530,7 +530,7 @@ else: self.send(str(data, 'ASCII', 'strict').lower().encode('ASCII', 'strict')) def handle_close(self): - if test_support.verbose: + if support.verbose: sys.stdout.write(" server: closed connection %s\n" % self.socket) def handle_error(self): @@ -546,7 +546,7 @@ else: def handle_accept(self): sock_obj, addr = self.accept() - if test_support.verbose: + if support.verbose: sys.stdout.write(" server: new connection from %s:%s\n" %addr) self.ConnectionHandler(sock_obj, self.certfile) @@ -556,7 +556,7 @@ else: def __init__(self, certfile): self.flag = None self.active = False - self.port = test_support.find_unused_port() + self.port = support.find_unused_port() self.server = self.EchoServer(self.port, certfile) threading.Thread.__init__(self) self.setDaemon(True) @@ -599,10 +599,10 @@ else: ssl_version=ssl.PROTOCOL_TLSv1) s.connect((HOST, server.port)) except ssl.SSLError as x: - if test_support.verbose: + if support.verbose: sys.stdout.write("\nSSLError is %s\n" % x) else: - raise test_support.TestFailed( + raise support.TestFailed( "Use of invalid cert should have failed!") finally: server.stop() @@ -635,28 +635,28 @@ else: ssl_version=client_protocol) s.connect((HOST, server.port)) except ssl.SSLError as x: - raise test_support.TestFailed("Unexpected SSL error: " + str(x)) + raise support.TestFailed("Unexpected SSL error: " + str(x)) except Exception as x: - raise test_support.TestFailed("Unexpected exception: " + str(x)) + raise support.TestFailed("Unexpected exception: " + str(x)) else: if connectionchatty: - if test_support.verbose: + if support.verbose: sys.stdout.write( " client: sending %s...\n" % (repr(indata))) s.write(indata.encode('ASCII', 'strict')) outdata = s.read() if connectionchatty: - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: read %s\n" % repr(outdata)) outdata = str(outdata, 'ASCII', 'strict') if outdata != indata.lower(): - raise test_support.TestFailed( + raise support.TestFailed( "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" % (repr(outdata[:min(len(outdata),20)]), len(outdata), repr(indata[:min(len(indata),20)].lower()), len(indata))) s.write("over\n".encode("ASCII", "strict")) if connectionchatty: - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() finally: @@ -677,7 +677,7 @@ else: certtype = "CERT_OPTIONAL" elif certsreqs == ssl.CERT_REQUIRED: certtype = "CERT_REQUIRED" - if test_support.verbose: + if support.verbose: formatstr = (expectedToWork and " %s->%s %s\n") or " {%s->%s} %s\n" sys.stdout.write(formatstr % (ssl.get_protocol_name(client_protocol), @@ -687,12 +687,12 @@ else: serverParamsTest(CERTFILE, server_protocol, certsreqs, CERTFILE, CERTFILE, client_protocol, chatty=False, connectionchatty=False) - except test_support.TestFailed: + except support.TestFailed: if expectedToWork: raise else: if not expectedToWork: - raise test_support.TestFailed( + raise support.TestFailed( "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol))) @@ -702,7 +702,7 @@ else: def testEcho (self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") serverParamsTest(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE, CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1, @@ -710,7 +710,7 @@ else: def testReadCert(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") s2 = socket.socket() server = ThreadedEchoServer(CERTFILE, @@ -732,30 +732,30 @@ else: ssl_version=ssl.PROTOCOL_SSLv23) s.connect((HOST, server.port)) except ssl.SSLError as x: - raise test_support.TestFailed( + raise support.TestFailed( "Unexpected SSL error: " + str(x)) except Exception as x: - raise test_support.TestFailed( + raise support.TestFailed( "Unexpected exception: " + str(x)) else: if not s: - raise test_support.TestFailed( + raise support.TestFailed( "Can't SSL-handshake with test server") cert = s.getpeercert() if not cert: - raise test_support.TestFailed( + raise support.TestFailed( "Can't get peer certificate.") cipher = s.cipher() - if test_support.verbose: + if support.verbose: sys.stdout.write(pprint.pformat(cert) + '\n') sys.stdout.write("Connection cipher is " + str(cipher) + '.\n') if 'subject' not in cert: - raise test_support.TestFailed( + raise support.TestFailed( "No subject field in certificate: %s." % pprint.pformat(cert)) if ((('organizationName', 'Python Software Foundation'),) not in cert['subject']): - raise test_support.TestFailed( + raise support.TestFailed( "Missing or invalid 'organizationName' field in certificate subject; " "should be 'Python Software Foundation'.") s.close() @@ -777,7 +777,7 @@ else: listener_ready = threading.Event() listener_gone = threading.Event() - port = test_support.find_unused_port() + port = support.find_unused_port() # `listener` runs in a thread. It opens a socket listening on # PORT, and sits in an accept() until the main thread connects. @@ -802,7 +802,7 @@ else: except IOError: pass else: - raise test_support.TestFailed( + raise support.TestFailed( 'connecting to closed SSL socket should have failed') t = threading.Thread(target=listener) @@ -811,7 +811,7 @@ else: t.join() def testProtocolSSL2(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) @@ -821,13 +821,13 @@ else: tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False) def testProtocolSSL23(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") try: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) - except test_support.TestFailed as x: + except support.TestFailed as x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) - if test_support.verbose: + if support.verbose: sys.stdout.write( " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n" % str(x)) @@ -844,7 +844,7 @@ else: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) def testProtocolSSL3(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True) tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) @@ -854,7 +854,7 @@ else: tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False) def testProtocolTLS1(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True) tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) @@ -884,13 +884,13 @@ else: s.setblocking(1) s.connect((HOST, server.port)) except Exception as x: - raise test_support.TestFailed("Unexpected exception: " + str(x)) + raise support.TestFailed("Unexpected exception: " + str(x)) else: - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") for indata in msgs: msg = indata.encode('ASCII', 'replace') - if test_support.verbose: + if support.verbose: sys.stdout.write( " client: sending %s...\n" % repr(msg)) if wrapped: @@ -901,7 +901,7 @@ else: outdata = s.recv(1024) if (indata == "STARTTLS" and str(outdata, 'ASCII', 'replace').strip().lower().startswith("ok")): - if test_support.verbose: + if support.verbose: msg = str(outdata, 'ASCII', 'replace') sys.stdout.write( " client: read %s from server, starting TLS...\n" @@ -910,11 +910,11 @@ else: wrapped = True else: - if test_support.verbose: + if support.verbose: msg = str(outdata, 'ASCII', 'replace') sys.stdout.write( " client: read %s from server\n" % repr(msg)) - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: closing connection.\n") if wrapped: conn.write("over\n".encode("ASCII", "strict")) @@ -937,7 +937,7 @@ else: flag.wait() # try to connect try: - if test_support.verbose: + if support.verbose: sys.stdout.write('\n') d1 = open(CERTFILE, 'rb').read() d2 = '' @@ -948,33 +948,33 @@ else: dlen = f.info().getheader("content-length") if dlen and (int(dlen) > 0): d2 = f.read(int(dlen)) - if test_support.verbose: + if support.verbose: sys.stdout.write( " client: read %d bytes from remote server '%s'\n" % (len(d2), server)) f.close() except: msg = ''.join(traceback.format_exception(*sys.exc_info())) - if test_support.verbose: + if support.verbose: sys.stdout.write('\n' + msg) - raise test_support.TestFailed(msg) + raise support.TestFailed(msg) else: if not (d1 == d2): print("d1 is", len(d1), repr(d1)) print("d2 is", len(d2), repr(d2)) - raise test_support.TestFailed( + raise support.TestFailed( "Couldn't fetch data from HTTPS server") finally: - if test_support.verbose: + if support.verbose: sys.stdout.write('stopping server\n') server.stop() - if test_support.verbose: + if support.verbose: sys.stdout.write('joining thread\n') server.join() def testAsyncoreServer(self): - if test_support.verbose: + if support.verbose: sys.stdout.write("\n") indata="FOO\n" @@ -988,25 +988,25 @@ else: s = ssl.wrap_socket(socket.socket()) s.connect((HOST, server.port)) except ssl.SSLError as x: - raise test_support.TestFailed("Unexpected SSL error: " + str(x)) + raise support.TestFailed("Unexpected SSL error: " + str(x)) except Exception as x: - raise test_support.TestFailed("Unexpected exception: " + str(x)) + raise support.TestFailed("Unexpected exception: " + str(x)) else: - if test_support.verbose: + if support.verbose: sys.stdout.write( " client: sending %s...\n" % (repr(indata))) s.sendall(indata.encode('ASCII', 'strict')) outdata = s.recv() - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: read %s\n" % repr(outdata)) outdata = str(outdata, 'ASCII', 'strict') if outdata != indata.lower(): - raise test_support.TestFailed( + raise support.TestFailed( "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" % (repr(outdata[:min(len(outdata),20)]), len(outdata), repr(indata[:min(len(indata),20)].lower()), len(indata))) s.write("over\n".encode("ASCII", "strict")) - if test_support.verbose: + if support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() finally: @@ -1015,7 +1015,7 @@ else: def test_main(verbose=False): if skip_expected: - raise test_support.TestSkipped("No SSL support") + raise support.TestSkipped("No SSL support") global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, @@ -1026,22 +1026,22 @@ def test_main(verbose=False): if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)): - raise test_support.TestFailed("Can't read certificate files!") + raise support.TestFailed("Can't read certificate files!") tests = [BasicTests] - if test_support.is_resource_enabled('network'): + if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: - thread_info = test_support.threading_setup() - if thread_info and test_support.is_resource_enabled('network'): + thread_info = support.threading_setup() + if thread_info and support.is_resource_enabled('network'): tests.append(ThreadedTests) - test_support.run_unittest(*tests) + support.run_unittest(*tests) if _have_threads: - test_support.threading_cleanup(*thread_info) + support.threading_cleanup(*thread_info) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py index db09946102..8d23dbb71e 100644 --- a/Lib/test/test_startfile.py +++ b/Lib/test/test_startfile.py @@ -8,7 +8,7 @@ # call succeeded, but also the the script actually has run. import unittest -from test import test_support +from test import support # use this form so that the test is skipped when startfile is not available: from os import startfile, path @@ -23,7 +23,7 @@ class TestCase(unittest.TestCase): startfile(empty, "open") def test_main(): - test_support.run_unittest(TestCase) + support.run_unittest(TestCase) if __name__=="__main__": test_main() diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py index 5af5a0c2c3..7128fd7408 100755 --- a/Lib/test/test_strftime.py +++ b/Lib/test/test_strftime.py @@ -6,7 +6,7 @@ import calendar import sys import os import re -from test import test_support +from test import support import time import unittest @@ -68,7 +68,7 @@ class StrftimeTest(unittest.TestCase): self.strftest1(now) self.strftest2(now) - if test_support.verbose: + if support.verbose: print("Strftime test, platform: %s, Python version: %s" % \ (sys.platform, sys.version.split()[0])) @@ -80,7 +80,7 @@ class StrftimeTest(unittest.TestCase): self.strftest2(arg) def strftest1(self, now): - if test_support.verbose: + if support.verbose: print("strftime test for", time.ctime(now)) now = self.now # Make sure any characters that could be taken as regex syntax is @@ -162,24 +162,24 @@ class StrftimeTest(unittest.TestCase): except ValueError as result: msg = "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) - if test_support.verbose: + if support.verbose: print(msg) continue if re.match(escapestr(e[1], self.ampm), result): - if test_support.verbose: + if support.verbose: print("Supports nonstandard '%s' format (%s)" % (e[0], e[2])) elif not result or result[0] == '%': - if test_support.verbose: + if support.verbose: print("Does not appear to support '%s' format (%s)" % \ (e[0], e[2])) else: - if test_support.verbose: + if support.verbose: print("Conflict for nonstandard '%s' format (%s):" % \ (e[0], e[2])) print(" Expected %s, but got %s" % (e[1], result)) def test_main(): - test_support.run_unittest(StrftimeTest) + support.run_unittest(StrftimeTest) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py index 4c3c964509..66f2204de4 100644 --- a/Lib/test/test_string.py +++ b/Lib/test/test_string.py @@ -1,5 +1,5 @@ import unittest, string -from test import test_support +from test import support class ModuleTest(unittest.TestCase): @@ -110,7 +110,7 @@ class ModuleTest(unittest.TestCase): self.assertRaises(TypeError, string.maketrans, 'abc', 'def') def test_main(): - test_support.run_unittest(ModuleTest) + support.run_unittest(ModuleTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_stringprep.py b/Lib/test/test_stringprep.py index 04527902a8..f3d3327ab0 100644 --- a/Lib/test/test_stringprep.py +++ b/Lib/test/test_stringprep.py @@ -2,7 +2,7 @@ # Since we don't have them, this test checks only a few codepoints. import unittest -from test import test_support +from test import support from stringprep import * @@ -90,7 +90,7 @@ class StringprepTests(unittest.TestCase): # print p, h.hexdigest() def test_main(): - test_support.run_unittest(StringprepTests) + support.run_unittest(StringprepTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index ac8905a299..436a487dff 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -5,7 +5,7 @@ import time import locale import re import sys -from test import test_support +from test import support from datetime import date as datetime_date import _strptime @@ -551,7 +551,7 @@ class CacheTests(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( getlang_Tests, LocaleTime_Tests, TimeRETests, diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 61b5f6ce26..05ac760bac 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -1,5 +1,5 @@ -from test.test_support import TestFailed, verbose, verify, vereq -import test.test_support +from test.support import TestFailed, verbose, verify, vereq +import test.support import struct import array import warnings @@ -50,7 +50,7 @@ def any_err(func, *args): def with_warning_restore(func): def _with_warning_restore(*args, **kw): - with test.test_support.catch_warning(): + with test.support.catch_warning(): # Grrr, we need this function to warn every time. Without removing # the warningregistry, running test_tarfile then test_struct would fail # on 64-bit platforms. diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py index 97d7b23830..d6c9fea217 100644 --- a/Lib/test/test_structmembers.py +++ b/Lib/test/test_structmembers.py @@ -6,7 +6,7 @@ from _testcapi import test_structmembersType, \ LLONG_MAX, LLONG_MIN, ULLONG_MAX import warnings, unittest, sys -from test import test_support +from test import support ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8, 9.99999, 10.1010101010) @@ -69,39 +69,39 @@ class TestWarnings(unittest.TestCase): self.assertEqual(w.category, RuntimeWarning) def test_byte_max(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_BYTE = CHAR_MAX+1 self.has_warned(w) def test_byte_min(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_BYTE = CHAR_MIN-1 self.has_warned(w) def test_ubyte_max(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_UBYTE = UCHAR_MAX+1 self.has_warned(w) def test_short_max(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_SHORT = SHRT_MAX+1 self.has_warned(w) def test_short_min(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_SHORT = SHRT_MIN-1 self.has_warned(w) def test_ushort_max(self): - with test_support.catch_warning() as w: + with support.catch_warning() as w: ts.T_USHORT = USHRT_MAX+1 self.has_warned(w) def test_main(verbose=None): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_structseq.py b/Lib/test/test_structseq.py index 7ba142bca8..124acff9f1 100644 --- a/Lib/test/test_structseq.py +++ b/Lib/test/test_structseq.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import time @@ -114,7 +114,7 @@ class StructSeqTest(unittest.TestCase): L[start:stop:step]) def test_main(): - test_support.run_unittest(StructSeqTest) + support.run_unittest(StructSeqTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 3d6777f1e7..5a325ce130 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import subprocess import sys import signal @@ -31,14 +31,14 @@ class ProcessTestCase(unittest.TestCase): def setUp(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). - if hasattr(test_support, "reap_children"): - test_support.reap_children() + if hasattr(support, "reap_children"): + support.reap_children() def tearDown(self): # Try to minimize the number of children we have so this test # doesn't crash on some buildbots (Alphas in particular). - if hasattr(test_support, "reap_children"): - test_support.reap_children() + if hasattr(support, "reap_children"): + support.reap_children() def mkstemp(self): """wrapper for mkstemp, calling mktemp if mkstemp is not available""" @@ -392,8 +392,8 @@ class ProcessTestCase(unittest.TestCase): def test_no_leaking(self): # Make sure we leak no resources - if (not hasattr(test_support, "is_resource_enabled") or - test_support.is_resource_enabled("subprocess") and not mswindows): + if (not hasattr(support, "is_resource_enabled") or + support.is_resource_enabled("subprocess") and not mswindows): max_handles = 1026 # too much for most UNIX systems else: max_handles = 65 @@ -703,9 +703,9 @@ class ProcessTestCase(unittest.TestCase): self.assertNotEqual(p.wait(), 0) def test_main(): - test_support.run_unittest(ProcessTestCase) - if hasattr(test_support, "reap_children"): - test_support.reap_children() + support.run_unittest(ProcessTestCase) + if hasattr(support, "reap_children"): + support.reap_children() if __name__ == "__main__": unittest.main() # XXX test_main() diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py index 1b6069dde0..292722d503 100644 --- a/Lib/test/test_sundry.py +++ b/Lib/test/test_sundry.py @@ -1,13 +1,13 @@ """Do a minimal test of all the modules that aren't otherwise tested.""" -from test import test_support +from test import support import sys import unittest import warnings class TestUntestedModules(unittest.TestCase): def test_at_least_import_untested_modules(self): - with test_support.catch_warning(): + with support.catch_warning(): import CGIHTTPServer import aifc import bdb @@ -73,14 +73,14 @@ class TestUntestedModules(unittest.TestCase): try: import tty # not available on Windows except ImportError: - if test_support.verbose: + if support.verbose: print("skipping tty") import webbrowser import xml def test_main(): - test_support.run_unittest(TestUntestedModules) + support.run_unittest(TestUntestedModules) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_super.py b/Lib/test/test_super.py index fc303eac73..5594b112a2 100644 --- a/Lib/test/test_super.py +++ b/Lib/test/test_super.py @@ -2,7 +2,7 @@ import sys import unittest -from test import test_support +from test import support class A: @@ -72,7 +72,7 @@ class TestSuper(unittest.TestCase): def test_main(): - test_support.run_unittest(TestSuper) + support.run_unittest(TestSuper) if __name__ == "__main__": diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 74a7c8559a..77115e0c78 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import symtable import unittest @@ -38,7 +38,7 @@ class SymtableTest(unittest.TestCase): def test_main(): - test_support.run_unittest(SymtableTest) + support.run_unittest(SymtableTest) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 546f7a8626..11ca4ea88b 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -476,7 +476,7 @@ import re import unittest import warnings -from test import test_support +from test import support class SyntaxTestCase(unittest.TestCase): @@ -548,9 +548,9 @@ class SyntaxTestCase(unittest.TestCase): self._check_error("int(base=10, '2')", "non-keyword arg") def test_main(): - test_support.run_unittest(SyntaxTestCase) + support.run_unittest(SyntaxTestCase) from test import test_syntax - test_support.run_doctest(test_syntax, verbosity=True) + support.run_doctest(test_syntax, verbosity=True) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 3a0abe1586..7c66e0d768 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -import unittest, test.test_support +import unittest, test.support import sys, io class SysModuleTest(unittest.TestCase): @@ -350,7 +350,7 @@ class SysModuleTest(unittest.TestCase): #self.assert_(r[0][2] > 100, r[0][2]) def test_main(): - test.test_support.run_unittest(SysModuleTest) + test.support.run_unittest(SysModuleTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_syslog.py b/Lib/test/test_syslog.py index 3f22c0da38..3a3d63555f 100644 --- a/Lib/test/test_syslog.py +++ b/Lib/test/test_syslog.py @@ -1,7 +1,7 @@ import syslog import unittest -from test import test_support +from test import support # XXX(nnorwitz): This test sucks. I don't know of a platform independent way # to verify that the messages were really logged. @@ -31,7 +31,7 @@ class Test(unittest.TestCase): syslog.LOG_UPTO(syslog.LOG_INFO) def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 2fbb51e6ad..9fde707a8f 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -10,7 +10,7 @@ import errno import unittest import tarfile -from test import test_support +from test import support # Check for our compression modules. try: @@ -27,7 +27,7 @@ def md5sum(data): return md5(data).hexdigest() def path(path): - return test_support.findfile(path) + return support.findfile(path) TEMPDIR = os.path.join(tempfile.gettempdir(), "test_tarfile_tmp") tarname = path("testtar.tar") @@ -1171,7 +1171,7 @@ def test_main(): ] try: - test_support.run_unittest(*tests) + support.run_unittest(*tests) finally: if os.path.exists(TEMPDIR): shutil.rmtree(TEMPDIR) diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 4255d8afa3..9a327dc185 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -2,7 +2,7 @@ import unittest import os -from test import test_support +from test import support from Tkinter import Tcl from _tkinter import TclError @@ -151,7 +151,7 @@ class TclTest(unittest.TestCase): os.environ['DISPLAY'] = old_display def test_main(): - test_support.run_unittest(TclTest) + support.run_unittest(TclTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py index e4ee1b5da7..c24d41d02d 100644 --- a/Lib/test/test_telnetlib.py +++ b/Lib/test/test_telnetlib.py @@ -4,9 +4,9 @@ import telnetlib import time from unittest import TestCase -from test import test_support +from test import support -HOST = test_support.HOST +HOST = support.HOST def server(evt, serv): serv.listen(5) @@ -25,7 +25,7 @@ class GeneralTests(TestCase): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(3) - self.port = test_support.bind_port(self.sock) + self.port = support.bind_port(self.sock) threading.Thread(target=server, args=(self.evt,self.sock)).start() self.evt.wait() self.evt.clear() @@ -71,7 +71,7 @@ class GeneralTests(TestCase): def test_main(verbose=None): - test_support.run_unittest(GeneralTests) + support.run_unittest(GeneralTests) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index e88efebbd8..5a81455213 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -7,7 +7,7 @@ import errno import warnings import unittest -from test import test_support +from test import support warnings.filterwarnings("ignore", category=RuntimeWarning, @@ -116,7 +116,7 @@ class test__RandomNameSequence(TC): self.failIf(s in dict) dict[s] = 1 - def test_supports_iter(self): + def supports_iter(self): # _RandomNameSequence supports the iterator protocol i = 0 @@ -276,7 +276,7 @@ class test__mkstemp_inner(TC): if not has_spawnl: return # ugh, can't use TestSkipped. - if test_support.verbose: + if support.verbose: v="v" else: v="q" @@ -881,7 +881,7 @@ if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile: test_classes.append(test_TemporaryFile) def test_main(): - test_support.run_unittest(*test_classes) + support.run_unittest(*test_classes) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index 1a9761a954..1cbd9cece0 100644 --- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -9,7 +9,7 @@ # import unittest -from test import test_support +from test import support from textwrap import TextWrapper, wrap, fill, dedent @@ -579,7 +579,7 @@ def foo(): def test_main(): - test_support.run_unittest(WrapTestCase, + support.run_unittest(WrapTestCase, LongWordTestCase, IndentTestCases, DedentTestCase) diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py index 01d6655295..cff9f81ff5 100644 --- a/Lib/test/test_thread.py +++ b/Lib/test/test_thread.py @@ -1,7 +1,7 @@ import os import unittest import random -from test import test_support +from test import support import thread import time @@ -13,7 +13,7 @@ _print_mutex = thread.allocate_lock() def verbose_print(arg): """Helper function for printing out debugging output.""" - if test_support.verbose: + if support.verbose: with _print_mutex: print(arg) @@ -159,7 +159,7 @@ class BarrierTest(BasicThreadTest): self.done_mutex.release() def test_main(): - test_support.run_unittest(ThreadRunningTests, BarrierTest) + support.run_unittest(ThreadRunningTests, BarrierTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py index 41a2b9099f..fbe479cd30 100644 --- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -6,7 +6,7 @@ # randrange, and then Python hangs. import thread -from test.test_support import verbose, TestSkipped, TestFailed +from test.support import verbose, TestSkipped, TestFailed critical_section = thread.allocate_lock() done = thread.allocate_lock() diff --git a/Lib/test/test_threadedtempfile.py b/Lib/test/test_threadedtempfile.py index cde15b42e2..fb122d0d87 100644 --- a/Lib/test/test_threadedtempfile.py +++ b/Lib/test/test_threadedtempfile.py @@ -20,7 +20,7 @@ import thread # If this fails, we can't test this module import threading import tempfile -from test.test_support import threading_setup, threading_cleanup, run_unittest +from test.support import threading_setup, threading_cleanup, run_unittest import unittest import io from traceback import print_exc diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 1017f56598..9582dde1e4 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -1,7 +1,7 @@ # Very rudimentary test of threading module -import test.test_support -from test.test_support import verbose +import test.support +from test.support import verbose import random import sys import threading @@ -356,7 +356,7 @@ class ThreadingExceptionTests(unittest.TestCase): def test_main(): - test.test_support.run_unittest(ThreadTests, + test.support.run_unittest(ThreadTests, ThreadingExceptionTests) if __name__ == "__main__": diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py index b7dd538f8e..e48dc5973b 100644 --- a/Lib/test/test_threading_local.py +++ b/Lib/test/test_threading_local.py @@ -1,6 +1,6 @@ import unittest from doctest import DocTestSuite -from test import test_support +from test import support import threading import weakref import gc @@ -62,7 +62,7 @@ def test_main(): setUp=setUp, tearDown=tearDown) ) - test_support.run_unittest(suite) + support.run_unittest(suite) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py index 2f014e146b..cbed42c002 100644 --- a/Lib/test/test_threadsignals.py +++ b/Lib/test/test_threadsignals.py @@ -5,7 +5,7 @@ import thread import signal import os import sys -from test.test_support import run_unittest, TestSkipped +from test.support import run_unittest, TestSkipped if sys.platform[:3] in ('win', 'os2'): raise TestSkipped("Can't test signal on %s" % sys.platform) diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 3a7fa0f4bc..4c89f03bab 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import time import unittest @@ -219,7 +219,7 @@ class TimeTestCase(unittest.TestCase): self.assert_(0 <= (t1-t0) < 0.2) def test_main(): - test_support.run_unittest(TimeTestCase) + support.run_unittest(TimeTestCase) if __name__ == "__main__": diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py index 6324fc1831..264704e7e2 100644 --- a/Lib/test/test_timeout.py +++ b/Lib/test/test_timeout.py @@ -1,10 +1,10 @@ """Unit tests for socket timeout feature.""" import unittest -from test import test_support +from test import support # This requires the 'network' resource as given on the regrtest command line. -skip_expected = not test_support.is_resource_enabled('network') +skip_expected = not support.is_resource_enabled('network') import time import socket @@ -191,8 +191,8 @@ class TimeoutTestCase(unittest.TestCase): def test_main(): - test_support.requires('network') - test_support.run_unittest(CreationTestCase, TimeoutTestCase) + support.requires('network') + support.run_unittest(CreationTestCase, TimeoutTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py index ea9030b7c7..8fbd216ac6 100644 --- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -60,7 +60,7 @@ two trailing blanks apparent in the expected output. ... " print(x)\\n") True - >>> f = test_support.findfile("tokenize_tests.txt") + >>> f = support.findfile("tokenize_tests.txt") >>> roundtrip(open(f, 'rb')) True @@ -522,7 +522,7 @@ pass the '-ucompiler' option to process the full directory. >>> tempdir = os.path.dirname(f) or os.curdir >>> testfiles = glob.glob(os.path.join(tempdir, "test*.py")) - >>> if not test_support.is_resource_enabled("compiler"): + >>> if not support.is_resource_enabled("compiler"): ... testfiles = random.sample(testfiles, 10) ... >>> for testfile in testfiles: @@ -533,7 +533,7 @@ pass the '-ucompiler' option to process the full directory. True """ -from test import test_support +from test import support from tokenize import (tokenize, _tokenize, untokenize, NUMBER, NAME, OP, STRING, ENDMARKER, tok_name, detect_encoding) from io import BytesIO @@ -842,11 +842,11 @@ __test__ = {"doctests" : doctests, 'decistmt': decistmt} def test_main(): from test import test_tokenize - test_support.run_doctest(test_tokenize, True) - test_support.run_unittest(TestTokenizerAdheresToPep0263) - test_support.run_unittest(Test_Tokenize) - test_support.run_unittest(TestDetectEncoding) - test_support.run_unittest(TestTokenize) + support.run_doctest(test_tokenize, True) + support.run_unittest(TestTokenizerAdheresToPep0263) + support.run_unittest(Test_Tokenize) + support.run_unittest(TestDetectEncoding) + support.run_unittest(TestTokenize) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index 9ecd995841..48a717ba8f 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -1,6 +1,6 @@ # Testing the line trace facility. -from test import test_support +from test import support import unittest import sys import difflib @@ -742,7 +742,7 @@ class JumpTestCase(unittest.TestCase): no_jump_without_trace_function() def test_main(): - test_support.run_unittest( + support.run_unittest( TraceTestCase, RaisingTraceFuncTestCase, JumpTestCase diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 600c7b5eef..3f89e6a795 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -4,7 +4,7 @@ from _testcapi import traceback_print from io import StringIO import sys import unittest -from test.test_support import run_unittest, is_jython, Error +from test.support import run_unittest, is_jython, Error import traceback diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py index 77672e7123..de081314db 100644 --- a/Lib/test/test_tuple.py +++ b/Lib/test/test_tuple.py @@ -1,4 +1,4 @@ -from test import test_support, seq_tests +from test import support, seq_tests class TupleTest(seq_tests.CommonTest): type2test = tuple @@ -83,7 +83,7 @@ class TupleTest(seq_tests.CommonTest): self.assertEqual(repr(a2), "(0, 1, 2)") def test_main(): - test_support.run_unittest(TupleTest) + support.run_unittest(TupleTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_typechecks.py b/Lib/test/test_typechecks.py index 1dcc82c186..901c32655d 100644 --- a/Lib/test/test_typechecks.py +++ b/Lib/test/test_typechecks.py @@ -1,7 +1,7 @@ """Unit tests for __instancecheck__ and __subclasscheck__.""" import unittest -from test import test_support +from test import support class ABC(type): @@ -56,7 +56,7 @@ class TypeChecksTest(unittest.TestCase): def test_main(): - test_support.run_unittest(TypeChecksTest) + support.run_unittest(TypeChecksTest) if __name__ == "__main__": diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 2fc0004790..948e8d4bae 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -1,6 +1,6 @@ # Python test set -- part 6, built-in types -from test.test_support import run_unittest, run_with_locale +from test.support import run_unittest, run_with_locale import unittest import sys import locale diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py index 78cb78042e..2d48179c59 100644 --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -9,7 +9,7 @@ Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com) import unittest -from test import test_support +from test import support class UnicodeNamesTest(unittest.TestCase): @@ -138,7 +138,7 @@ class UnicodeNamesTest(unittest.TestCase): ) def test_main(): - test_support.run_unittest(UnicodeNamesTest) + support.run_unittest(UnicodeNamesTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_unary.py b/Lib/test/test_unary.py index dbefe62310..7dd651e8db 100644 --- a/Lib/test/test_unary.py +++ b/Lib/test/test_unary.py @@ -1,7 +1,7 @@ """Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2""" import unittest -from test.test_support import run_unittest +from test.support import run_unittest class UnaryOpTestCase(unittest.TestCase): diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index c64dee5544..2f9add5ec3 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -11,7 +11,7 @@ import struct import sys import unittest import warnings -from test import test_support, string_tests +from test import support, string_tests # Error handling (bad decoder return) def search_function(encoding): @@ -671,7 +671,7 @@ class UnicodeTest( return '\u1234' self.assertEqual('%s' % Wrapper(), '\u1234') - @test_support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR') + @support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR') def test_format_float(self): # should not format with a comma, but always with C locale self.assertEqual('1.0', '%.1f' % 1.0) @@ -1077,7 +1077,7 @@ class UnicodeTest( def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py index 5f0681e479..cc670db922 100644 --- a/Lib/test/test_unicode_file.py +++ b/Lib/test/test_unicode_file.py @@ -5,8 +5,8 @@ import os, glob, time, shutil import unicodedata import unittest -from test.test_support import run_unittest, TestSkipped, TESTFN_UNICODE -from test.test_support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE +from test.support import run_unittest, TestSkipped, TESTFN_UNICODE +from test.support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE try: TESTFN_UNICODE.encode(TESTFN_ENCODING) except (UnicodeError, TypeError): diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py index c4ea816b6d..08208f960c 100644 --- a/Lib/test/test_unicodedata.py +++ b/Lib/test/test_unicodedata.py @@ -5,7 +5,7 @@ (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" -import unittest, test.test_support +import unittest, test.support import hashlib encoding = 'utf-8' @@ -219,7 +219,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest): self.assertEquals(self.db.lookup("GOTHIC LETTER FAIHU"), '\U00010346') def test_main(): - test.test_support.run_unittest( + test.support.run_unittest( UnicodeMiscTest, UnicodeMethodsTest, UnicodeFunctionsTest diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index ed27618eea..c9c17d3dff 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -6,7 +6,7 @@ Still need testing: TestCase.{assert,fail}* methods (some are tested implicitly) """ -from test import test_support +from test import support import unittest from unittest import TestCase import types @@ -2289,7 +2289,7 @@ class Test_Assertions(TestCase): ###################################################################### def test_main(): - test_support.run_unittest(Test_TestCase, Test_TestLoader, + support.run_unittest(Test_TestCase, Test_TestLoader, Test_TestSuite, Test_TestResult, Test_FunctionTestCase, Test_Assertions) diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py index c3b7bc44ca..c4e4a3fbbb 100644 --- a/Lib/test/test_univnewlines.py +++ b/Lib/test/test_univnewlines.py @@ -2,10 +2,10 @@ import unittest import os import sys -from test import test_support +from test import support if not hasattr(sys.stdin, 'newlines'): - raise test_support.TestSkipped( + raise support.TestSkipped( "This Python does not have universal newline support") FATX = 'x' * (2**14) @@ -35,7 +35,7 @@ class TestGenericUnivNewlines(unittest.TestCase): WRITEMODE = 'wb' def setUp(self): - fp = open(test_support.TESTFN, self.WRITEMODE) + fp = open(support.TESTFN, self.WRITEMODE) data = self.DATA if "b" in self.WRITEMODE: data = data.encode("ascii") @@ -44,24 +44,24 @@ class TestGenericUnivNewlines(unittest.TestCase): def tearDown(self): try: - os.unlink(test_support.TESTFN) + os.unlink(support.TESTFN) except: pass def test_read(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) data = fp.read() self.assertEqual(data, DATA_LF) self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) def test_readlines(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) data = fp.readlines() self.assertEqual(data, DATA_SPLIT) self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) def test_readline(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) data = [] d = fp.readline() while d: @@ -71,7 +71,7 @@ class TestGenericUnivNewlines(unittest.TestCase): self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) def test_seek(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) fp.readline() pos = fp.tell() data = fp.readlines() @@ -94,7 +94,7 @@ class TestCRLFNewlines(TestGenericUnivNewlines): DATA = DATA_CRLF def test_tell(self): - fp = open(test_support.TESTFN, self.READMODE) + fp = open(support.TESTFN, self.READMODE) self.assertEqual(repr(fp.newlines), repr(None)) data = fp.readline() pos = fp.tell() @@ -106,7 +106,7 @@ class TestMixedNewlines(TestGenericUnivNewlines): def test_main(): - test_support.run_unittest( + support.run_unittest( TestCRNewlines, TestLFNewlines, TestCRLFNewlines, diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py index a90b5e5c18..b1531f306d 100644 --- a/Lib/test/test_unpack.py +++ b/Lib/test/test_unpack.py @@ -122,9 +122,9 @@ error) __test__ = {'doctests' : doctests} def test_main(verbose=False): - from test import test_support + from test import support from test import test_unpack - test_support.run_doctest(test_unpack, verbose) + support.run_doctest(test_unpack, verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_unpack_ex.py b/Lib/test/test_unpack_ex.py index 89486b8d2d..ae2dcbd985 100644 --- a/Lib/test/test_unpack_ex.py +++ b/Lib/test/test_unpack_ex.py @@ -166,9 +166,9 @@ __test__ = {'doctests' : doctests} def test_main(verbose=False): import sys - from test import test_support + from test import support from test import test_unpack_ex - test_support.run_doctest(test_unpack_ex, verbose) + support.run_doctest(test_unpack_ex, verbose) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index d58414cf25..7db281cb90 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -4,7 +4,7 @@ import urllib import httplib import io import unittest -from test import test_support +from test import support import os import mimetools import tempfile @@ -27,18 +27,18 @@ class urlopen_FileTests(unittest.TestCase): def setUp(self): """Setup of a temp file to use for testing""" self.text = bytes("test_urllib: %s\n" % self.__class__.__name__, "ascii") - FILE = open(test_support.TESTFN, 'wb') + FILE = open(support.TESTFN, 'wb') try: FILE.write(self.text) finally: FILE.close() - self.pathname = test_support.TESTFN + self.pathname = support.TESTFN self.returned_obj = urllib.urlopen("file:%s" % self.pathname) def tearDown(self): """Shut down the open object""" self.returned_obj.close() - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_interface(self): # Make sure object returned by urlopen() has the specified methods @@ -163,10 +163,10 @@ class urlretrieve_FileTests(unittest.TestCase): self.tempFiles = [] # Create a temporary file. - self.registerFileForCleanUp(test_support.TESTFN) + self.registerFileForCleanUp(support.TESTFN) self.text = b'testing urllib.urlretrieve' try: - FILE = open(test_support.TESTFN, 'wb') + FILE = open(support.TESTFN, 'wb') FILE.write(self.text) FILE.close() finally: @@ -204,18 +204,18 @@ class urlretrieve_FileTests(unittest.TestCase): def test_basic(self): # Make sure that a local file just gets its own location returned and # a headers value is returned. - result = urllib.urlretrieve("file:%s" % test_support.TESTFN) - self.assertEqual(result[0], test_support.TESTFN) + result = urllib.urlretrieve("file:%s" % support.TESTFN) + self.assertEqual(result[0], support.TESTFN) self.assert_(isinstance(result[1], mimetools.Message), "did not get a mimetools.Message instance as second " "returned value") def test_copy(self): # Test that setting the filename argument works. - second_temp = "%s.2" % test_support.TESTFN + second_temp = "%s.2" % support.TESTFN self.registerFileForCleanUp(second_temp) result = urllib.urlretrieve(self.constructLocalFileUrl( - test_support.TESTFN), second_temp) + support.TESTFN), second_temp) self.assertEqual(second_temp, result[0]) self.assert_(os.path.exists(second_temp), "copy of the file was not " "made") @@ -236,9 +236,9 @@ class urlretrieve_FileTests(unittest.TestCase): self.assert_(isinstance(total_size, int)) self.assertEqual(count, count_holder[0]) count_holder[0] = count_holder[0] + 1 - second_temp = "%s.2" % test_support.TESTFN + second_temp = "%s.2" % support.TESTFN self.registerFileForCleanUp(second_temp) - urllib.urlretrieve(self.constructLocalFileUrl(test_support.TESTFN), + urllib.urlretrieve(self.constructLocalFileUrl(support.TESTFN), second_temp, hooktester) def test_reporthook_0_bytes(self): @@ -248,7 +248,7 @@ class urlretrieve_FileTests(unittest.TestCase): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile() urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), - test_support.TESTFN, hooktester) + support.TESTFN, hooktester) self.assertEqual(len(report), 1) self.assertEqual(report[0][2], 0) @@ -262,7 +262,7 @@ class urlretrieve_FileTests(unittest.TestCase): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile(b"x" * 5) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), - test_support.TESTFN, hooktester) + support.TESTFN, hooktester) self.assertEqual(len(report), 2) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 5) @@ -276,7 +276,7 @@ class urlretrieve_FileTests(unittest.TestCase): _report.append((count, block_size, total_size)) srcFileName = self.createNewTempFile(b"x" * 8193) urllib.urlretrieve(self.constructLocalFileUrl(srcFileName), - test_support.TESTFN, hooktester) + support.TESTFN, hooktester) self.assertEqual(len(report), 3) self.assertEqual(report[0][1], 8192) self.assertEqual(report[0][2], 8193) @@ -632,7 +632,7 @@ class Pathname_Tests(unittest.TestCase): def test_main(): - test_support.run_unittest( + support.run_unittest( urlopen_FileTests, urlopen_HttpTests, urlretrieve_FileTests, diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index d34a17746e..cb730e2057 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import os import io @@ -588,7 +588,7 @@ class HandlerTests(unittest.TestCase): h = urllib2.FileHandler() o = h.parent = MockOpener() - TESTFN = test_support.TESTFN + TESTFN = support.TESTFN urlpath = sanepathname2url(os.path.abspath(TESTFN)) towrite = b"hello, world\n" urls = [ @@ -1075,13 +1075,13 @@ class MiscTests(unittest.TestCase): def test_main(verbose=None): from test import test_urllib2 - test_support.run_doctest(test_urllib2, verbose) - test_support.run_doctest(urllib2, verbose) + support.run_doctest(test_urllib2, verbose) + support.run_doctest(urllib2, verbose) tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests) - test_support.run_unittest(*tests) + support.run_unittest(*tests) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py index 0815658602..6bf1820f22 100644 --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -7,7 +7,7 @@ import urllib2 import BaseHTTPServer import unittest import hashlib -from test import test_support +from test import support # Loopback http server infrastructure @@ -481,10 +481,10 @@ def test_main(): # (Lib/test/regrtest.py -u network) since all tests here are only # localhost. However, if this is a bad rationale, then uncomment # the next line. - #test_support.requires("network") + #support.requires("network") - test_support.run_unittest(ProxyAuthTests) - test_support.run_unittest(TestUrlopen) + support.run_unittest(ProxyAuthTests) + support.run_unittest(TestUrlopen) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py index 75df9fd7b9..89e48cb9d5 100644 --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import unittest -from test import test_support +from test import support from test.test_urllib2 import sanepathname2url import socket @@ -105,7 +105,7 @@ class OtherNetworkTests(unittest.TestCase): self._test_urls(urls, self._extra_handlers()) def test_file(self): - TESTFN = test_support.TESTFN + TESTFN = support.TESTFN f = open(TESTFN, 'w') try: f.write('hi there\n') @@ -169,7 +169,7 @@ class OtherNetworkTests(unittest.TestCase): (expected_err, url, req, type(err), err)) self.assert_(isinstance(err, expected_err), msg) else: - with test_support.transient_internet(): + with support.transient_internet(): buf = f.read() f.close() debug("read %d bytes" % len(buf)) @@ -233,8 +233,8 @@ class TimeoutTest(unittest.TestCase): def test_main(): - test_support.requires("network") - test_support.run_unittest(AuthTests, + support.requires("network") + support.run_unittest(AuthTests, OtherNetworkTests, CloseSocketTest, TimeoutTest, diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py index 6fd4684241..6c2632c55a 100644 --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import unittest -from test import test_support +from test import support import socket import urllib @@ -166,8 +166,8 @@ class urlretrieveNetworkTests(unittest.TestCase): def test_specified_path(self): # Make sure that specifying the location of the file to write to works. file_location,info = self.urlretrieve("http://www.python.org/", - test_support.TESTFN) - self.assertEqual(file_location, test_support.TESTFN) + support.TESTFN) + self.assertEqual(file_location, support.TESTFN) self.assert_(os.path.exists(file_location)) FILE = open(file_location, errors='ignore') try: @@ -186,8 +186,8 @@ class urlretrieveNetworkTests(unittest.TestCase): def test_main(): - test_support.requires('network') - test_support.run_unittest(URLTimeoutTest, + support.requires('network') + support.run_unittest(URLTimeoutTest, urlopenNetworkTests, urlretrieveNetworkTests) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 8ab8f35c21..02b2f6f109 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -from test import test_support +from test import support import unittest import urlparse @@ -311,7 +311,7 @@ class UrlParseTestCase(unittest.TestCase): ('http', 'example.com', '', '', 'blahblah=/foo', '')) def test_main(): - test_support.run_unittest(UrlParseTestCase) + support.run_unittest(UrlParseTestCase) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py index 3a8a8b4925..30eec71935 100644 --- a/Lib/test/test_userdict.py +++ b/Lib/test/test_userdict.py @@ -1,6 +1,6 @@ # Check every path through every method of UserDict -from test import test_support, mapping_tests +from test import support, mapping_tests import collections d0 = {} @@ -190,7 +190,7 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol): def test_main(): - test_support.run_unittest( + support.run_unittest( UserDictTest, ) diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py index a0daa4e8ed..868ed24ccc 100644 --- a/Lib/test/test_userlist.py +++ b/Lib/test/test_userlist.py @@ -1,7 +1,7 @@ # Check every path through every method of UserList from collections import UserList -from test import test_support, list_tests +from test import support, list_tests class UserListTest(list_tests.CommonTest): type2test = UserList @@ -53,7 +53,7 @@ class UserListTest(list_tests.CommonTest): self.assertEqual(next(iter(T((1,2)))), "0!!!") def test_main(): - test_support.run_unittest(UserListTest) + support.run_unittest(UserListTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py index e8fb13507b..05381384bf 100755 --- a/Lib/test/test_userstring.py +++ b/Lib/test/test_userstring.py @@ -3,7 +3,7 @@ # UserString instances should behave similar to builtin string objects. import string -from test import test_support, string_tests +from test import support, string_tests from collections import UserString @@ -43,7 +43,7 @@ class UserStringTest( def test_main(): - test_support.run_unittest(UserStringTest) + support.run_unittest(UserStringTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py index b4bb32be00..02d0171c37 100644 --- a/Lib/test/test_uu.py +++ b/Lib/test/test_uu.py @@ -4,7 +4,7 @@ Nick Mathewson """ import unittest -from test import test_support +from test import support import sys, os import uu @@ -111,8 +111,8 @@ class UUFileTest(unittest.TestCase): pass def setUp(self): - self.tmpin = test_support.TESTFN + "i" - self.tmpout = test_support.TESTFN + "o" + self.tmpin = support.TESTFN + "i" + self.tmpout = support.TESTFN + "o" def tearDown(self): del self.tmpin @@ -121,7 +121,7 @@ class UUFileTest(unittest.TestCase): def test_encode(self): fin = fout = None try: - test_support.unlink(self.tmpin) + support.unlink(self.tmpin) fin = open(self.tmpin, 'wb') fin.write(plaintext) fin.close() @@ -151,7 +151,7 @@ class UUFileTest(unittest.TestCase): def test_decode(self): f = None try: - test_support.unlink(self.tmpin) + support.unlink(self.tmpin) f = open(self.tmpin, 'wb') f.write(encodedtextwrapped(0o644, self.tmpout)) f.close() @@ -185,7 +185,7 @@ class UUFileTest(unittest.TestCase): self._kill(f) def test_main(): - test_support.run_unittest(UUTest, + support.run_unittest(UUTest, UUStdIOTest, UUFileTest, ) diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 92d62946e1..5a37c2fde3 100644 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -1,5 +1,5 @@ from unittest import TestCase -from test import test_support +from test import support import uuid def importable(name): @@ -462,7 +462,7 @@ class TestUUID(TestCase): def test_main(): - test_support.run_unittest(TestUUID) + support.run_unittest(TestUUID) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_wait3.py b/Lib/test/test_wait3.py index 3adbec4abc..4cca441853 100644 --- a/Lib/test/test_wait3.py +++ b/Lib/test/test_wait3.py @@ -4,7 +4,7 @@ import os import time from test.fork_wait import ForkWait -from test.test_support import TestSkipped, run_unittest, reap_children +from test.support import TestSkipped, run_unittest, reap_children try: os.fork diff --git a/Lib/test/test_wait4.py b/Lib/test/test_wait4.py index c85944d06a..192fd94041 100644 --- a/Lib/test/test_wait4.py +++ b/Lib/test/test_wait4.py @@ -4,7 +4,7 @@ import os import time from test.fork_wait import ForkWait -from test.test_support import TestSkipped, run_unittest, reap_children +from test.support import TestSkipped, run_unittest, reap_children try: os.fork diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index 7b512ef3d6..6fb3c0ea3e 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -4,7 +4,7 @@ import os from io import StringIO import sys import unittest -from test import test_support +from test import support from test import warning_tests @@ -72,21 +72,21 @@ class FilterTests(object): """Testing the filtering functionality.""" def test_error(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("error", category=UserWarning) self.assertRaises(UserWarning, self.module.warn, "FilterTests.test_error") def test_ignore(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("ignore", category=UserWarning) self.module.warn("FilterTests.test_ignore", UserWarning) self.assert_(not w.message) def test_always(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("always", category=UserWarning) message = "FilterTests.test_always" @@ -97,7 +97,7 @@ class FilterTests(object): self.assert_(w.message, message) def test_default(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("default", category=UserWarning) message = UserWarning("FilterTests.test_default") @@ -112,7 +112,7 @@ class FilterTests(object): raise ValueError("loop variant unhandled") def test_module(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("module", category=UserWarning) message = UserWarning("FilterTests.test_module") @@ -123,7 +123,7 @@ class FilterTests(object): self.assert_(not w.message, "unexpected message: " + str(w)) def test_once(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("once", category=UserWarning) message = UserWarning("FilterTests.test_once") @@ -139,14 +139,14 @@ class FilterTests(object): self.assert_(not w.message) def test_inheritance(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("error", category=Warning) self.assertRaises(UserWarning, self.module.warn, "FilterTests.test_inheritance", UserWarning) def test_ordering(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("ignore", category=UserWarning) self.module.filterwarnings("error", category=UserWarning, @@ -161,7 +161,7 @@ class FilterTests(object): def test_filterwarnings(self): # Test filterwarnings(). # Implicitly also tests resetwarnings(). - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.filterwarnings("error", "", Warning, "", 0) self.assertRaises(UserWarning, self.module.warn, 'convert to error') @@ -196,7 +196,7 @@ class WarnTests(unittest.TestCase): """Test warnings.warn() and warnings.warn_explicit().""" def test_message(self): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: for i in range(4): text = 'multi %d' %i # Different text on each call. self.module.warn(text) @@ -205,7 +205,7 @@ class WarnTests(unittest.TestCase): def test_filename(self): with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner("spam1") self.assertEqual(os.path.basename(w.filename), "warning_tests.py") warning_tests.outer("spam2") @@ -215,7 +215,7 @@ class WarnTests(unittest.TestCase): # Test stacklevel argument # make sure all messages are different, so the warning won't be skipped with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner("spam3", stacklevel=1) self.assertEqual(os.path.basename(w.filename), "warning_tests.py") warning_tests.outer("spam4", stacklevel=1) @@ -238,7 +238,7 @@ class WarnTests(unittest.TestCase): try: del warning_tests.__file__ with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner("spam8", stacklevel=1) self.assertEqual(w.filename, warning_tests.__name__) finally: @@ -255,7 +255,7 @@ class WarnTests(unittest.TestCase): del warning_tests.__file__ warning_tests.__name__ = '__main__' with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner('spam9', stacklevel=1) self.assertEqual(w.filename, sys.argv[0]) finally: @@ -273,7 +273,7 @@ class WarnTests(unittest.TestCase): warning_tests.__name__ = '__main__' del sys.argv with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner('spam10', stacklevel=1) self.assertEqual(w.filename, '__main__') finally: @@ -293,7 +293,7 @@ class WarnTests(unittest.TestCase): warning_tests.__name__ = '__main__' sys.argv = [''] with warnings_state(self.module): - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: warning_tests.inner('spam11', stacklevel=1) self.assertEqual(w.filename, '__main__') finally: @@ -315,7 +315,7 @@ class WCmdLineTests(unittest.TestCase): def test_improper_input(self): # Uses the private _setoption() function to test the parsing # of command-line warning arguments - with test_support.catch_warning(self.module): + with support.catch_warning(self.module): self.assertRaises(self.module._OptionError, self.module._setoption, '1:2:3:4:5:6') self.assertRaises(self.module._OptionError, @@ -340,7 +340,7 @@ class _WarningsTests(BaseTest): def test_filter(self): # Everything should function even if 'filters' is not in warnings. - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.filterwarnings("error", "", Warning, "", 0) self.assertRaises(UserWarning, self.module.warn, 'convert to error') @@ -355,7 +355,7 @@ class _WarningsTests(BaseTest): try: original_registry = self.module.onceregistry __warningregistry__ = {} - with test_support.catch_warning(self.module) as w: + with support.catch_warning(self.module) as w: self.module.resetwarnings() self.module.filterwarnings("once", category=UserWarning) self.module.warn_explicit(message, UserWarning, "file", 42) @@ -380,10 +380,10 @@ class _WarningsTests(BaseTest): def test_showwarning_missing(self): # Test that showwarning() missing is okay. text = 'del showwarning test' - with test_support.catch_warning(self.module): + with support.catch_warning(self.module): self.module.filterwarnings("always", category=UserWarning) del self.module.showwarning - with test_support.captured_output('stderr') as stream: + with support.captured_output('stderr') as stream: self.module.warn(text) result = stream.getvalue() self.failUnless(text in result) @@ -401,10 +401,10 @@ class _WarningsTests(BaseTest): def test_show_warning_output(self): # With showarning() missing, make sure that output is okay. text = 'test show_warning' - with test_support.catch_warning(self.module): + with support.catch_warning(self.module): self.module.filterwarnings("always", category=UserWarning) del self.module.showwarning - with test_support.captured_output('stderr') as stream: + with support.captured_output('stderr') as stream: warning_tests.inner(text) result = stream.getvalue() self.failUnlessEqual(result.count('\n'), 2, @@ -476,7 +476,7 @@ class PyWarningsDisplayTests(BaseTest, WarningsDisplayTests): def test_main(): py_warnings.onceregistry.clear() c_warnings.onceregistry.clear() - test_support.run_unittest(CFilterTests, + support.run_unittest(CFilterTests, PyFilterTests, CWarnTests, PyWarnTests, diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py index c37323a21b..a7746fd8c2 100644 --- a/Lib/test/test_wave.py +++ b/Lib/test/test_wave.py @@ -1,4 +1,4 @@ -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest import os import wave import unittest diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 7de7b77d09..303345befe 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -4,7 +4,7 @@ import unittest import collections import weakref -from test import test_support +from test import support # Used in ReferencesTestCase.test_ref_created_during_del() . ref_from_del = None @@ -1145,13 +1145,13 @@ OK __test__ = {'libreftest' : libreftest} def test_main(): - test_support.run_unittest( + support.run_unittest( ReferencesTestCase, MappingTestCase, WeakValueDictionaryTestCase, WeakKeyDictionaryTestCase, ) - test_support.run_doctest(sys.modules[__name__]) + support.run_doctest(sys.modules[__name__]) if __name__ == "__main__": diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py index 7f5b8eb544..cff2045556 100644 --- a/Lib/test/test_weakset.py +++ b/Lib/test/test_weakset.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support from weakref import proxy, ref, WeakSet import operator import copy @@ -306,7 +306,7 @@ class TestWeakSet(unittest.TestCase): def test_main(verbose=None): - test_support.run_unittest(TestWeakSet) + support.run_unittest(TestWeakSet) if __name__ == "__main__": test_main(verbose=True) diff --git a/Lib/test/test_whichdb.py b/Lib/test/test_whichdb.py index e63eb0fe76..d908ac5b3b 100644 --- a/Lib/test/test_whichdb.py +++ b/Lib/test/test_whichdb.py @@ -4,14 +4,14 @@ """ import os -import test.test_support +import test.support import unittest import whichdb import anydbm import glob from test.test_anydbm import delete_files, dbm_iterator -_fname = test.test_support.TESTFN +_fname = test.support.TESTFN class WhichDBTestCase(unittest.TestCase): # Actual test methods are added to namespace @@ -27,7 +27,7 @@ class WhichDBTestCase(unittest.TestCase): name = module.__name__ if name == 'dumbdbm': continue # whichdb can't support dumbdbm - test.test_support.unlink(_fname) + test.support.unlink(_fname) f = module.open(_fname, 'c') f.close() self.assertEqual(name, whichdb.whichdb(_fname)) @@ -50,7 +50,7 @@ class WhichDBTestCase(unittest.TestCase): def test_main(): try: - test.test_support.run_unittest(WhichDBTestCase) + test.support.run_unittest(WhichDBTestCase) finally: delete_files() diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py index 174d7bcee8..e852c69684 100644 --- a/Lib/test/test_winreg.py +++ b/Lib/test/test_winreg.py @@ -6,7 +6,7 @@ from _winreg import * import os, sys import unittest -from test import test_support +from test import support test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me" @@ -161,7 +161,7 @@ class WinregTests(unittest.TestCase): self.assertEqual(r, os.environ["windir"] + "\\test") def test_main(): - test_support.run_unittest(WinregTests) + support.run_unittest(WinregTests) if __name__ == "__main__": try: diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py index bc21d7eed1..c39a233ca8 100644 --- a/Lib/test/test_winsound.py +++ b/Lib/test/test_winsound.py @@ -1,8 +1,8 @@ # Ridiculously simple test of the winsound module for Windows. import unittest -from test import test_support -test_support.requires('audio') +from test import support +support.requires('audio') import winsound, time import os import subprocess @@ -226,7 +226,7 @@ def _have_soundcard(): def test_main(): - test_support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest) + support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest) if __name__=="__main__": test_main() diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py index 6e439ac7a1..43f3271228 100644 --- a/Lib/test/test_with.py +++ b/Lib/test/test_with.py @@ -10,7 +10,7 @@ import sys import unittest from collections import deque from contextlib import GeneratorContextManager, contextmanager -from test.test_support import run_unittest +from test.support import run_unittest class MockContextManager(GeneratorContextManager): diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py index a5e0b27796..ac5ada3b99 100755 --- a/Lib/test/test_wsgiref.py +++ b/Lib/test/test_wsgiref.py @@ -11,7 +11,7 @@ from io import StringIO, BytesIO, BufferedReader from socketserver import BaseServer import re, sys -from test import test_support +from test import support class MockServer(WSGIServer): """Non-socket HTTP server""" @@ -578,7 +578,7 @@ class HandlerTests(TestCase): # This epilogue is needed for compatibility with the Python 2.5 regrtest module def test_main(): - test_support.run_unittest(__name__) + support.run_unittest(__name__) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_xdrlib.py b/Lib/test/test_xdrlib.py index 44d5a82c71..11a44ff93b 100644 --- a/Lib/test/test_xdrlib.py +++ b/Lib/test/test_xdrlib.py @@ -1,4 +1,4 @@ -from test import test_support +from test import support import unittest import xdrlib @@ -50,7 +50,7 @@ class XDRTest(unittest.TestCase): self.assertRaises(EOFError, up.unpack_uint) def test_main(): - test_support.run_unittest(XDRTest) + support.run_unittest(XDRTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 84705841e0..895902f02f 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -5,7 +5,7 @@ import doctest import sys -from test import test_support +from test import support SAMPLE_XML = """ <body> @@ -345,7 +345,7 @@ def xinclude(): def test_main(): from test import test_xml_etree - test_support.run_doctest(test_xml_etree, verbosity=True) + support.run_doctest(test_xml_etree, verbosity=True) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py index 80e91d14af..4d28d01222 100644 --- a/Lib/test/test_xml_etree_c.py +++ b/Lib/test/test_xml_etree_c.py @@ -3,7 +3,7 @@ import doctest import sys -from test import test_support +from test import support from xml.etree import cElementTree as ET @@ -214,7 +214,7 @@ def bug_1534630(): def test_main(): from test import test_xml_etree_c - test_support.run_doctest(test_xml_etree_c, verbosity=True) + support.run_doctest(test_xml_etree_c, verbosity=True) if __name__ == '__main__': test_main() diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index 7ff078db91..cad2b9dc3b 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -10,7 +10,7 @@ import mimetools import httplib import socket import os -from test import test_support +from test import support alist = [{'astring': 'foo@bar.baz.spam', 'afloat': 7283.43, @@ -546,20 +546,20 @@ class CGIHandlerTestCase(unittest.TestCase): # if the method is GET and no request_text is given, it runs handle_get # get sysout output tmp = sys.stdout - sys.stdout = open(test_support.TESTFN, "w") + sys.stdout = open(support.TESTFN, "w") self.cgi.handle_request() sys.stdout.close() sys.stdout = tmp # parse Status header - handle = open(test_support.TESTFN, "r").read() + handle = open(support.TESTFN, "r").read() status = handle.split()[1] message = ' '.join(handle.split()[2:4]) self.assertEqual(status, '400') self.assertEqual(message, 'Bad Request') - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) os.environ['REQUEST_METHOD'] = '' def test_cgi_xmlrpc_response(self): @@ -581,7 +581,7 @@ class CGIHandlerTestCase(unittest.TestCase): tmp2 = sys.stdout sys.stdin = open("xmldata.txt", "r") - sys.stdout = open(test_support.TESTFN, "w") + sys.stdout = open(support.TESTFN, "w") self.cgi.handle_request() @@ -591,13 +591,13 @@ class CGIHandlerTestCase(unittest.TestCase): sys.stdout = tmp2 # will respond exception, if so, our goal is achieved ;) - handle = open(test_support.TESTFN, "r").read() + handle = open(support.TESTFN, "r").read() # start with 44th char so as not to get http header, we just need only xml self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:]) os.remove("xmldata.txt") - os.remove(test_support.TESTFN) + os.remove(support.TESTFN) def test_main(): xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase, @@ -612,7 +612,7 @@ def test_main(): xmlrpc_tests.append(FailingServerTestCase) xmlrpc_tests.append(CGIHandlerTestCase) - test_support.run_unittest(*xmlrpc_tests) + support.run_unittest(*xmlrpc_tests) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_xmlrpc_net.py b/Lib/test/test_xmlrpc_net.py index e62fcb6fae..1f8dd5d1e5 100644 --- a/Lib/test/test_xmlrpc_net.py +++ b/Lib/test/test_xmlrpc_net.py @@ -4,7 +4,7 @@ import errno import socket import sys import unittest -from test import test_support +from test import support import xmlrpclib @@ -37,8 +37,8 @@ class CurrentTimeTest(unittest.TestCase): def test_main(): - test_support.requires("network") - test_support.run_unittest(CurrentTimeTest) + support.requires("network") + support.run_unittest(CurrentTimeTest) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 6878262556..30efeb964a 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -8,8 +8,8 @@ import zipfile, os, unittest, sys, shutil, struct, io from tempfile import TemporaryFile from random import randint, random -import test.test_support as support -from test.test_support import TESTFN, run_unittest +import test.support as support +from test.support import TESTFN, run_unittest TESTFN2 = TESTFN + "2" FIXEDTEST_SIZE = 1000 diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py index a008fd0313..343fd4f0e2 100644 --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -1,11 +1,11 @@ # Tests of the full ZIP64 functionality of zipfile -# The test_support.requires call is the only reason for keeping this separate +# The support.requires call is the only reason for keeping this separate # from test_zipfile -from test import test_support +from test import support # XXX(nnorwitz): disable this test by looking for extra largfile resource # which doesn't exist. This test takes over 30 minutes to run in general # and requires more disk space than most of the buildbots. -test_support.requires( +support.requires( 'extralargefile', 'test requires loads of disk-space bytes and a long time to run' ) @@ -23,7 +23,7 @@ import sys from io import StringIO from tempfile import TemporaryFile -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest TESTFN2 = TESTFN + "2" diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index c7da859e6e..754476a695 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -8,7 +8,7 @@ import unittest import zlib # implied prerequisite from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED -from test import test_support +from test import support from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co import zipimport @@ -385,12 +385,12 @@ class BadFileZipImportTestCase(unittest.TestCase): self.assertZipFailure('A' * 33000) def testEmptyFile(self): - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) open(TESTMOD, 'w+').close() self.assertZipFailure(TESTMOD) def testFileUnreadable(self): - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) fd = os.open(TESTMOD, os.O_CREAT, 000) try: os.close(fd) @@ -399,10 +399,10 @@ class BadFileZipImportTestCase(unittest.TestCase): # If we leave "the read-only bit" set on Windows, nothing can # delete TESTMOD, and later tests suffer bogus failures. os.chmod(TESTMOD, 0o666) - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) def testNotZipFile(self): - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) fp = open(TESTMOD, 'w+') fp.write('a' * 22) fp.close() @@ -410,7 +410,7 @@ class BadFileZipImportTestCase(unittest.TestCase): # XXX: disabled until this works on Big-endian machines def _testBogusZipFile(self): - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) fp = open(TESTMOD, 'w+') fp.write(struct.pack('=I', 0x06054B50)) fp.write('a' * 18) @@ -451,13 +451,13 @@ def cleanup(): def test_main(): cleanup() try: - test_support.run_unittest( + support.run_unittest( UncompressedZipImportTestCase, CompressedZipImportTestCase, BadFileZipImportTestCase, ) finally: - test_support.unlink(TESTMOD) + support.unlink(TESTMOD) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 4fa263d118..485ffdc2fb 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -1,5 +1,5 @@ import unittest -from test import test_support +from test import support import zlib import binascii import random @@ -460,7 +460,7 @@ LAERTES def test_main(): - test_support.run_unittest( + support.run_unittest( ChecksumTestCase, ExceptionTestCase, CompressTestCase, diff --git a/Lib/test/xmltests.py b/Lib/test/xmltests.py index 446fe308a1..0bfcba181e 100644 --- a/Lib/test/xmltests.py +++ b/Lib/test/xmltests.py @@ -2,9 +2,9 @@ # standard library. import sys -import test.test_support +import test.support -test.test_support.verbose = 0 +test.support.verbose = 0 def runtest(name): __import__(name) |