summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-05-01 17:45:56 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2003-05-01 17:45:56 (GMT)
commit21d3a32b99c5763444c34c189ef653ac9745f3c4 (patch)
tree766baf21fbced41da1e22490829fe938420600e0
parent90437c03f2215acebffec9669316b40d46bd9757 (diff)
downloadcpython-21d3a32b99c5763444c34c189ef653ac9745f3c4.zip
cpython-21d3a32b99c5763444c34c189ef653ac9745f3c4.tar.gz
cpython-21d3a32b99c5763444c34c189ef653ac9745f3c4.tar.bz2
Combine the functionality of test_support.run_unittest()
and test_support.run_classtests() into run_unittest() and use it wherever possible. Also don't use "from test.test_support import ...", but "from test import test_support" in a few spots. From SF patch #662807.
-rw-r--r--Lib/test/test_StringIO.py10
-rw-r--r--Lib/test/test___all__.py4
-rw-r--r--Lib/test/test_base64.py34
-rw-r--r--Lib/test/test_bisect.py3
-rw-r--r--Lib/test/test_bool.py2
-rw-r--r--Lib/test/test_builtin.py4
-rw-r--r--Lib/test/test_bz2.py13
-rw-r--r--Lib/test/test_calendar.py4
-rw-r--r--Lib/test/test_call.py4
-rw-r--r--Lib/test/test_cfgparser.py10
-rw-r--r--Lib/test/test_charmapcodec.py4
-rw-r--r--Lib/test/test_codeccallbacks.py4
-rw-r--r--Lib/test/test_codecs.py14
-rw-r--r--Lib/test/test_copy.py4
-rw-r--r--Lib/test/test_cpickle.py13
-rw-r--r--Lib/test/test_csv.py18
-rw-r--r--Lib/test/test_dummy_thread.py6
-rw-r--r--Lib/test/test_enumerate.py8
-rw-r--r--Lib/test/test_filecmp.py5
-rw-r--r--Lib/test/test_getargs2.py8
-rwxr-xr-xLib/test/test_grp.py4
-rw-r--r--Lib/test/test_hexoct.py4
-rw-r--r--Lib/test/test_hmac.py12
-rw-r--r--Lib/test/test_isinstance.py10
-rw-r--r--Lib/test/test_itertools.py4
-rw-r--r--Lib/test/test_optparse.py15
-rw-r--r--Lib/test/test_os.py49
-rw-r--r--Lib/test/test_parser.py9
-rw-r--r--Lib/test/test_pep277.py26
-rw-r--r--Lib/test/test_pickle.py11
-rw-r--r--Lib/test/test_posix.py38
-rw-r--r--Lib/test/test_pow.py4
-rw-r--r--Lib/test/test_profilehooks.py9
-rw-r--r--Lib/test/test_pwd.py4
-rw-r--r--Lib/test/test_re.py6
-rw-r--r--Lib/test/test_richcmp.py2
-rw-r--r--Lib/test/test_sets.py56
-rw-r--r--Lib/test/test_shelve.py18
-rw-r--r--Lib/test/test_shutil.py10
-rw-r--r--Lib/test/test_socket.py21
-rw-r--r--Lib/test/test_str.py4
-rw-r--r--Lib/test/test_string.py5
-rw-r--r--Lib/test/test_strptime.py16
-rw-r--r--Lib/test/test_support.py15
-rw-r--r--Lib/test/test_sys.py4
-rw-r--r--Lib/test/test_tarfile.py37
-rw-r--r--Lib/test/test_tempfile.py5
-rw-r--r--Lib/test/test_textwrap.py6
-rw-r--r--Lib/test/test_timeout.py5
-rw-r--r--Lib/test/test_trace.py8
-rw-r--r--Lib/test/test_ucn.py4
-rw-r--r--Lib/test/test_unicode.py4
-rw-r--r--Lib/test/test_unicodedata.py10
-rw-r--r--Lib/test/test_univnewlines.py12
-rw-r--r--Lib/test/test_urllib.py16
-rw-r--r--Lib/test/test_urllibnet.py5
-rw-r--r--Lib/test/test_userdict.py10
-rw-r--r--Lib/test/test_userlist.py4
-rwxr-xr-xLib/test/test_userstring.py4
-rw-r--r--Lib/test/test_weakref.py12
-rw-r--r--Lib/test/test_xpickle.py10
-rw-r--r--Lib/test/test_zipimport.py6
-rw-r--r--Lib/test/test_zlib.py24
63 files changed, 309 insertions, 401 deletions
diff --git a/Lib/test/test_StringIO.py b/Lib/test/test_StringIO.py
index 74bdf59..8c367e8 100644
--- a/Lib/test/test_StringIO.py
+++ b/Lib/test/test_StringIO.py
@@ -105,10 +105,12 @@ class TestBuffercStringIO(TestcStringIO):
def test_main():
- test_support.run_unittest(TestStringIO)
- test_support.run_unittest(TestcStringIO)
- test_support.run_unittest(TestBufferStringIO)
- test_support.run_unittest(TestBuffercStringIO)
+ test_support.run_unittest(
+ TestStringIO,
+ TestcStringIO,
+ TestBufferStringIO,
+ TestBuffercStringIO
+ )
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 85ee598..66e6eeb 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -192,9 +192,7 @@ class AllTest(unittest.TestCase):
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(AllTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(AllTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py
index dfd67a3..f9f75f0 100644
--- a/Lib/test/test_base64.py
+++ b/Lib/test/test_base64.py
@@ -1,16 +1,16 @@
-from unittest import TestCase
-from test.test_support import vereq, run_unittest
-from base64 import encodestring, decodestring
+import unittest
+from test import test_support
+import base64
-class Base64TestCase(TestCase):
+class Base64TestCase(unittest.TestCase):
def test_encodestring(self):
- vereq(encodestring("www.python.org"), "d3d3LnB5dGhvbi5vcmc=\n")
- vereq(encodestring("a"), "YQ==\n")
- vereq(encodestring("ab"), "YWI=\n")
- vereq(encodestring("abc"), "YWJj\n")
- vereq(encodestring(""), "")
- vereq(encodestring("abcdefghijklmnopqrstuvwxyz"
+ self.assertEqual(base64.encodestring("www.python.org"), "d3d3LnB5dGhvbi5vcmc=\n")
+ self.assertEqual(base64.encodestring("a"), "YQ==\n")
+ self.assertEqual(base64.encodestring("ab"), "YWI=\n")
+ self.assertEqual(base64.encodestring("abc"), "YWJj\n")
+ self.assertEqual(base64.encodestring(""), "")
+ self.assertEqual(base64.encodestring("abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789!@#0^&*();:<>,. []{}"),
"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
@@ -18,20 +18,20 @@ class Base64TestCase(TestCase):
"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n")
def test_decodestring(self):
- vereq(decodestring("d3d3LnB5dGhvbi5vcmc=\n"), "www.python.org")
- vereq(decodestring("YQ==\n"), "a")
- vereq(decodestring("YWI=\n"), "ab")
- vereq(decodestring("YWJj\n"), "abc")
- vereq(decodestring("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
+ self.assertEqual(base64.decodestring("d3d3LnB5dGhvbi5vcmc=\n"), "www.python.org")
+ self.assertEqual(base64.decodestring("YQ==\n"), "a")
+ self.assertEqual(base64.decodestring("YWI=\n"), "ab")
+ self.assertEqual(base64.decodestring("YWJj\n"), "abc")
+ self.assertEqual(base64.decodestring("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n"),
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789!@#0^&*();:<>,. []{}")
- vereq(decodestring(''), '')
+ self.assertEqual(base64.decodestring(''), '')
def test_main():
- run_unittest(Base64TestCase)
+ test_support.run_unittest(Base64TestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py
index f30114d..549978d 100644
--- a/Lib/test/test_bisect.py
+++ b/Lib/test/test_bisect.py
@@ -198,8 +198,7 @@ __test__ = {'libreftest' : libreftest}
def test_main(verbose=None):
from test import test_bisect
- test_support.run_classtests(TestBisect,
- TestInsort)
+ test_support.run_unittest(TestBisect, TestInsort)
test_support.run_doctest(test_bisect, verbose)
if __name__ == "__main__":
diff --git a/Lib/test/test_bool.py b/Lib/test/test_bool.py
index aa05944..4fbb0b1 100644
--- a/Lib/test/test_bool.py
+++ b/Lib/test/test_bool.py
@@ -321,7 +321,7 @@ class BoolTest(unittest.TestCase):
self.assertEqual(cPickle.dumps(False, True), "I00\n.")
def test_main():
- test_support.run_classtests(BoolTest)
+ test_support.run_unittest(BoolTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index e5c9770..505da70 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1219,9 +1219,7 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(ValueError, zip, BadSeq(), BadSeq())
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(BuiltinTest))
- test.test_support.run_suite(suite)
+ test.test_support.run_unittest(BuiltinTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index 64ce6ab..5280ba8 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -309,13 +309,12 @@ class FuncTest(BaseTest):
self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10])
def test_main():
- suite = unittest.TestSuite()
- for test in (BZ2FileTest,
- BZ2CompressorTest,
- BZ2DecompressorTest,
- FuncTest):
- suite.addTest(unittest.makeSuite(test))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ BZ2FileTest,
+ BZ2CompressorTest,
+ BZ2DecompressorTest,
+ FuncTest
+ )
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index c0b746b..f8c6d56 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -1,7 +1,7 @@
import calendar
import unittest
-from test.test_support import run_unittest
+from test import test_support
class CalendarTestCase(unittest.TestCase):
@@ -55,7 +55,7 @@ class CalendarTestCase(unittest.TestCase):
self.assertEqual(len(d), 13)
def test_main():
- run_unittest(CalendarTestCase)
+ test_support.run_unittest(CalendarTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
index 695ab56..99554c7 100644
--- a/Lib/test/test_call.py
+++ b/Lib/test/test_call.py
@@ -1,5 +1,5 @@
import unittest
-from test.test_support import run_unittest
+from test import test_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():
- run_unittest(CFunctionCalls)
+ test_support.run_unittest(CFunctionCalls)
if __name__ == "__main__":
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index bc0ef5e..b1b495e 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -322,11 +322,11 @@ class SafeConfigParserTestCase(ConfigParserTestCase):
def test_main():
- suite = unittest.TestSuite()
- suite.addTests([unittest.makeSuite(ConfigParserTestCase),
- unittest.makeSuite(RawConfigParserTestCase),
- unittest.makeSuite(SafeConfigParserTestCase)])
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ ConfigParserTestCase,
+ RawConfigParserTestCase,
+ SafeConfigParserTestCase
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_charmapcodec.py b/Lib/test/test_charmapcodec.py
index 337d6e5..79d82c1 100644
--- a/Lib/test/test_charmapcodec.py
+++ b/Lib/test/test_charmapcodec.py
@@ -39,9 +39,7 @@ class CharmapCodecTest(unittest.TestCase):
self.assertRaises(UnicodeError, unicode, 'abc\001', codecname)
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(CharmapCodecTest))
- test.test_support.run_suite(suite)
+ test.test_support.run_unittest(CharmapCodecTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py
index 5c7243a..134d86c 100644
--- a/Lib/test/test_codeccallbacks.py
+++ b/Lib/test/test_codeccallbacks.py
@@ -659,9 +659,7 @@ class CodecCallbackTest(unittest.TestCase):
self.assertRaises(TypeError, u"\xff".translate, {0xff: ()})
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(CodecCallbackTest))
- test.test_support.run_suite(suite)
+ test.test_support.run_unittest(CodecCallbackTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index d451c1b..33a62aa 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -333,13 +333,13 @@ class NameprepTest(unittest.TestCase):
raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(UTF16Test))
- suite.addTest(unittest.makeSuite(EscapeDecodeTest))
- suite.addTest(unittest.makeSuite(RecodingTest))
- suite.addTest(unittest.makeSuite(PunycodeTest))
- suite.addTest(unittest.makeSuite(NameprepTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ UTF16Test,
+ EscapeDecodeTest,
+ RecodingTest,
+ PunycodeTest,
+ NameprepTest
+ )
if __name__ == "__main__":
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index cde545d..0e39e83 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -516,9 +516,7 @@ class TestCopy(unittest.TestCase):
self.assert_(x[0] is not y[0])
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestCopy))
- test_support.run_suite(suite)
+ test_support.run_unittest(TestCopy)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_cpickle.py b/Lib/test/test_cpickle.py
index 238fff2..d87decd 100644
--- a/Lib/test/test_cpickle.py
+++ b/Lib/test/test_cpickle.py
@@ -92,13 +92,12 @@ class cPickleFastPicklerTests(AbstractPickleTests):
self.assertEqual(a, b)
def test_main():
- loader = unittest.TestLoader()
- suite = unittest.TestSuite()
- suite.addTest(loader.loadTestsFromTestCase(cPickleTests))
- suite.addTest(loader.loadTestsFromTestCase(cPicklePicklerTests))
- suite.addTest(loader.loadTestsFromTestCase(cPickleListPicklerTests))
- suite.addTest(loader.loadTestsFromTestCase(cPickleFastPicklerTests))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ cPickleTests,
+ cPicklePicklerTests,
+ cPickleListPicklerTests,
+ cPickleFastPicklerTests
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index c4d1a03..18f8851 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -6,7 +6,7 @@ import unittest
from StringIO import StringIO
import csv
import gc
-from test.test_support import verbose
+from test import test_support
class Test_Csv(unittest.TestCase):
"""
@@ -568,7 +568,7 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back
self.assertEqual(dialect.skipinitialspace, False)
if not hasattr(sys, "gettotalrefcount"):
- if verbose: print "*** skipping leakage tests ***"
+ if test_support.verbose: print "*** skipping leakage tests ***"
else:
class NUL:
def write(s, *args):
@@ -640,15 +640,11 @@ else:
# if writer leaks during write, last delta should be 5 or more
self.assertEqual(delta < 5, True)
-def _testclasses():
+def test_main():
mod = sys.modules[__name__]
- return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
-
-def suite():
- suite = unittest.TestSuite()
- for testclass in _testclasses():
- suite.addTest(unittest.makeSuite(testclass))
- return suite
+ test_support.run_unittest(
+ *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
+ )
if __name__ == '__main__':
- unittest.main(defaultTest='suite')
+ test_main()
diff --git a/Lib/test/test_dummy_thread.py b/Lib/test/test_dummy_thread.py
index 7237670..0d614e1 100644
--- a/Lib/test/test_dummy_thread.py
+++ b/Lib/test/test_dummy_thread.py
@@ -162,11 +162,7 @@ def test_main(imported_module=None):
if test_support.verbose:
print
print "*** Using %s as _thread module ***" % _thread
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(LockTests))
- suite.addTest(unittest.makeSuite(MiscTests))
- suite.addTest(unittest.makeSuite(ThreadTests))
- test_support.run_suite(suite)
+ test_support.run_unittest(LockTests, MiscTests, ThreadTests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py
index 1fa9479..701b0c0 100644
--- a/Lib/test/test_enumerate.py
+++ b/Lib/test/test_enumerate.py
@@ -104,14 +104,8 @@ class SubclassTestCase(EnumerateTestCase):
enum = MyEnum
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(EnumerateTestCase))
- suite.addTest(unittest.makeSuite(SubclassTestCase))
- return suite
-
def test_main():
- test_support.run_suite(suite())
+ test_support.run_unittest(EnumerateTestCase, SubclassTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py
index 282cba6..0e5f297 100644
--- a/Lib/test/test_filecmp.py
+++ b/Lib/test/test_filecmp.py
@@ -119,10 +119,7 @@ class DirCompareTestCase(unittest.TestCase):
def test_main():
- suite = unittest.TestSuite()
- for cls in FileCompareTestCase, DirCompareTestCase:
- suite.addTest(unittest.makeSuite(cls))
- test_support.run_suite(suite)
+ test_support.run_unittest(FileCompareTestCase, DirCompareTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index aaa64e0..587fe1f 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -223,16 +223,14 @@ class LongLong_TestCase(unittest.TestCase):
self.failUnlessEqual(VERY_LARGE & ULLONG_MAX, getargs_K(VERY_LARGE))
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Signed_TestCase))
- suite.addTest(unittest.makeSuite(Unsigned_TestCase))
+ tests = [Signed_TestCase, Unsigned_TestCase]
try:
from _testcapi import getargs_L, getargs_K
except ImportError:
pass # PY_LONG_LONG not available
else:
- suite.addTest(unittest.makeSuite(LongLong_TestCase))
- test_support.run_suite(suite)
+ tests.append(LongLong_TestCase)
+ test_support.run_unittest(*tests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index 4b95a1a..6304d82 100755
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -97,9 +97,7 @@ class GroupDatabaseTestCase(unittest.TestCase):
self.assertRaises(KeyError, grp.getgrgid, fakegid)
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(GroupDatabaseTestCase))
- test_support.run_suite(suite)
+ test_support.run_unittest(GroupDatabaseTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_hexoct.py b/Lib/test/test_hexoct.py
index a14a2c2..8a57906 100644
--- a/Lib/test/test_hexoct.py
+++ b/Lib/test/test_hexoct.py
@@ -118,9 +118,7 @@ class TextHexOct(unittest.TestCase):
\n"""
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TextHexOct))
- test_support.run_suite(suite)
+ test_support.run_unittest(TextHexOct)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index f36db4e..4f1454f 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -103,12 +103,12 @@ class CopyTestCase(unittest.TestCase):
"Hexdigest of copy doesn't match original hexdigest.")
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestVectorsTestCase))
- suite.addTest(unittest.makeSuite(ConstructorTestCase))
- suite.addTest(unittest.makeSuite(SanityTestCase))
- suite.addTest(unittest.makeSuite(CopyTestCase))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ TestVectorsTestCase,
+ ConstructorTestCase,
+ SanityTestCase,
+ CopyTestCase
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py
index 5a19387..1b8c593 100644
--- a/Lib/test/test_isinstance.py
+++ b/Lib/test/test_isinstance.py
@@ -248,11 +248,11 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestIsInstanceExceptions))
- suite.addTest(unittest.makeSuite(TestIsSubclassExceptions))
- suite.addTest(unittest.makeSuite(TestIsInstanceIsSubclass))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ TestIsInstanceExceptions,
+ TestIsSubclassExceptions,
+ TestIsInstanceIsSubclass
+ )
if __name__ == '__main__':
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 4c506d0..2a60959 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -162,9 +162,7 @@ __test__ = {'libreftest' : libreftest}
def test_main(verbose=None):
import test_itertools
suite = unittest.TestSuite()
- for testclass in (TestBasicOps,
- ):
- suite.addTest(unittest.makeSuite(testclass))
+ suite.addTest(unittest.makeSuite(TestBasicOps))
test_support.run_suite(suite)
test_support.run_doctest(test_itertools, verbose)
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 4c9a42d..4712446 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -1193,18 +1193,11 @@ class TestMatchAbbrev(BaseTest):
"ambiguous option: --f (%s?)" % possibilities,
funcargs=[s, wordmap])
-def _testclasses():
- mod = sys.modules[__name__]
- return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
-
-def suite():
- suite = unittest.TestSuite()
- for testclass in _testclasses():
- suite.addTest(unittest.makeSuite(testclass))
- return suite
-
def test_main():
- test_support.run_suite(suite())
+ mod = sys.modules[__name__]
+ test_support.run_unittest(
+ *[getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
+ )
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 9ea1d06..028ec08 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -5,21 +5,20 @@
import os
import unittest
import warnings
+from test import test_support
warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
-from test.test_support import TESTFN, run_classtests
-
class TemporaryFileTests(unittest.TestCase):
def setUp(self):
self.files = []
- os.mkdir(TESTFN)
+ os.mkdir(test_support.TESTFN)
def tearDown(self):
for name in self.files:
os.unlink(name)
- os.rmdir(TESTFN)
+ os.rmdir(test_support.TESTFN)
def check_tempfile(self, name):
# make sure it doesn't already exist:
@@ -36,10 +35,10 @@ class TemporaryFileTests(unittest.TestCase):
r"test_os$")
self.check_tempfile(os.tempnam())
- name = os.tempnam(TESTFN)
+ name = os.tempnam(test_support.TESTFN)
self.check_tempfile(name)
- name = os.tempnam(TESTFN, "pfx")
+ name = os.tempnam(test_support.TESTFN, "pfx")
self.assert_(os.path.basename(name)[:3] == "pfx")
self.check_tempfile(name)
@@ -84,15 +83,15 @@ class TemporaryFileTests(unittest.TestCase):
# Test attributes on return values from os.*stat* family.
class StatAttributeTests(unittest.TestCase):
def setUp(self):
- os.mkdir(TESTFN)
- self.fname = os.path.join(TESTFN, "f1")
+ os.mkdir(test_support.TESTFN)
+ self.fname = os.path.join(test_support.TESTFN, "f1")
f = open(self.fname, 'wb')
f.write("ABC")
f.close()
def tearDown(self):
os.unlink(self.fname)
- os.rmdir(TESTFN)
+ os.rmdir(test_support.TESTFN)
def test_stat_attributes(self):
if not hasattr(os, "stat"):
@@ -238,10 +237,10 @@ class WalkTests(unittest.TestCase):
# SUB11/ no kids
# SUB2/ just a file kid
# tmp3
- sub1_path = join(TESTFN, "SUB1")
+ sub1_path = join(test_support.TESTFN, "SUB1")
sub11_path = join(sub1_path, "SUB11")
- sub2_path = join(TESTFN, "SUB2")
- tmp1_path = join(TESTFN, "tmp1")
+ sub2_path = join(test_support.TESTFN, "SUB2")
+ tmp1_path = join(test_support.TESTFN, "tmp1")
tmp2_path = join(sub1_path, "tmp2")
tmp3_path = join(sub2_path, "tmp3")
@@ -254,39 +253,39 @@ class WalkTests(unittest.TestCase):
f.close()
# Walk top-down.
- all = list(os.walk(TESTFN))
+ all = list(os.walk(test_support.TESTFN))
self.assertEqual(len(all), 4)
# We can't know which order SUB1 and SUB2 will appear in.
# Not flipped: TESTFN, SUB1, SUB11, SUB2
# flipped: TESTFN, SUB2, SUB1, SUB11
flipped = all[0][1][0] != "SUB1"
all[0][1].sort()
- self.assertEqual(all[0], (TESTFN, ["SUB1", "SUB2"], ["tmp1"]))
+ self.assertEqual(all[0], (test_support.TESTFN, ["SUB1", "SUB2"], ["tmp1"]))
self.assertEqual(all[1 + flipped], (sub1_path, ["SUB11"], ["tmp2"]))
self.assertEqual(all[2 + flipped], (sub11_path, [], []))
self.assertEqual(all[3 - 2 * flipped], (sub2_path, [], ["tmp3"]))
# Prune the search.
all = []
- for root, dirs, files in os.walk(TESTFN):
+ for root, dirs, files in os.walk(test_support.TESTFN):
all.append((root, dirs, files))
# Don't descend into SUB1.
if 'SUB1' in dirs:
# Note that this also mutates the dirs we appended to all!
dirs.remove('SUB1')
self.assertEqual(len(all), 2)
- self.assertEqual(all[0], (TESTFN, ["SUB2"], ["tmp1"]))
+ self.assertEqual(all[0], (test_support.TESTFN, ["SUB2"], ["tmp1"]))
self.assertEqual(all[1], (sub2_path, [], ["tmp3"]))
# Walk bottom-up.
- all = list(os.walk(TESTFN, topdown=False))
+ all = list(os.walk(test_support.TESTFN, topdown=False))
self.assertEqual(len(all), 4)
# We can't know which order SUB1 and SUB2 will appear in.
# Not flipped: SUB11, SUB1, SUB2, TESTFN
# flipped: SUB2, SUB11, SUB1, TESTFN
flipped = all[3][1][0] != "SUB1"
all[3][1].sort()
- self.assertEqual(all[3], (TESTFN, ["SUB1", "SUB2"], ["tmp1"]))
+ self.assertEqual(all[3], (test_support.TESTFN, ["SUB1", "SUB2"], ["tmp1"]))
self.assertEqual(all[flipped], (sub11_path, [], []))
self.assertEqual(all[flipped + 1], (sub1_path, ["SUB11"], ["tmp2"]))
self.assertEqual(all[2 - 2 * flipped], (sub2_path, [], ["tmp3"]))
@@ -295,18 +294,20 @@ 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(TESTFN, topdown=False):
+ for root, dirs, files in os.walk(test_support.TESTFN, topdown=False):
for name in files:
os.remove(join(root, name))
for name in dirs:
os.rmdir(join(root, name))
- os.rmdir(TESTFN)
+ os.rmdir(test_support.TESTFN)
def test_main():
- run_classtests(TemporaryFileTests,
- StatAttributeTests,
- EnvironTests,
- WalkTests)
+ test_support.run_unittest(
+ TemporaryFileTests,
+ StatAttributeTests,
+ EnvironTests,
+ WalkTests
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index ccdfd19..7860e7b 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -374,11 +374,10 @@ class IllegalSyntaxTestCase(unittest.TestCase):
self.check_bad_tree(tree, "malformed global ast")
def test_main():
- loader = unittest.TestLoader()
- suite = unittest.TestSuite()
- suite.addTest(loader.loadTestsFromTestCase(RoundtripLegalSyntaxTestCase))
- suite.addTest(loader.loadTestsFromTestCase(IllegalSyntaxTestCase))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ RoundtripLegalSyntaxTestCase,
+ IllegalSyntaxTestCase
+ )
if __name__ == "__main__":
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py
index 7173b89..9dc232c 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 os, unittest
-from test.test_support import TESTFN, TestSkipped, TestFailed, run_suite
+from test import test_support
if not os.path.supports_unicode_filenames:
- raise TestSkipped, "test works only on NT+"
+ raise test_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(TESTFN, f) for f in filenames]
+ files = [os.path.join(test_support.TESTFN, f) for f in filenames]
def setUp(self):
try:
- os.mkdir(TESTFN)
+ os.mkdir(test_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(TESTFN)
+ deltree(test_support.TESTFN)
def _apply_failure(self, fn, filename, expected_exception,
check_fn_in_exception = True):
try:
fn(filename)
- raise TestFailed("Expected to fail calling '%s(%r)'"
+ raise test_support.TestFailed("Expected to fail calling '%s(%r)'"
% (fn.__name__, filename))
except expected_exception, details:
if check_fn_in_exception and details.filename != filename:
- raise TestFailed("Function '%s(%r) failed with "
+ raise test_support.TestFailed("Function '%s(%r) failed with "
"bad filename in the exception: %r"
% (fn.__name__, filename,
details.filename))
@@ -77,9 +77,9 @@ class UnicodeFileTests(unittest.TestCase):
os.stat(name)
def test_listdir(self):
- f1 = os.listdir(TESTFN)
+ f1 = os.listdir(test_support.TESTFN)
f1.sort()
- f2 = os.listdir(unicode(TESTFN,"mbcs"))
+ f2 = os.listdir(unicode(test_support.TESTFN,"mbcs"))
f2.sort()
print f1
print f2
@@ -90,7 +90,7 @@ class UnicodeFileTests(unittest.TestCase):
os.rename("tmp",name)
def test_directory(self):
- dirname = os.path.join(TESTFN,u'Gr\xfc\xdf-\u66e8\u66e9\u66eb')
+ dirname = os.path.join(test_support.TESTFN,u'Gr\xfc\xdf-\u66e8\u66e9\u66eb')
filename = u'\xdf-\u66e8\u66e9\u66eb'
oldwd = os.getcwd()
os.mkdir(dirname)
@@ -104,12 +104,10 @@ class UnicodeFileTests(unittest.TestCase):
os.rmdir(dirname)
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(UnicodeFileTests))
try:
- run_suite(suite)
+ test_support.run_unittest(UnicodeFileTests)
finally:
- deltree(TESTFN)
+ deltree(test_support.TESTFN)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index 9cfb9b7..585644e 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -62,12 +62,11 @@ class PersPicklerTests(AbstractPersistentPicklerTests):
return u.load()
def test_main():
- loader = unittest.TestLoader()
- suite = unittest.TestSuite()
- suite.addTest(loader.loadTestsFromTestCase(PickleTests))
- suite.addTest(loader.loadTestsFromTestCase(PicklerTests))
- suite.addTest(loader.loadTestsFromTestCase(PersPicklerTests))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ PickleTests,
+ PicklerTests,
+ PersPicklerTests
+ )
test_support.run_doctest(pickle)
if __name__ == "__main__":
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 5a0028c..6b4272f 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1,11 +1,11 @@
"Test posix functions"
-from test.test_support import TestSkipped, TestFailed, TESTFN, run_suite
+from test import test_support
try:
import posix
except ImportError:
- raise TestSkipped, "posix is not available"
+ raise test_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(TESTFN, 'w+')
+ fp = open(test_support.TESTFN, 'w+')
fp.close()
def tearDown(self):
- os.unlink(TESTFN)
+ os.unlink(test_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(TESTFN)
+ fp = open(test_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(TESTFN, 'w+')
+ fp = open(test_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(TESTFN)
+ fp = open(test_support.TESTFN)
try:
fd = posix.dup(fp.fileno())
self.assert_(isinstance(fd, int))
@@ -75,8 +75,8 @@ class PosixTester(unittest.TestCase):
def test_dup2(self):
if hasattr(posix, 'dup2'):
- fp1 = open(TESTFN)
- fp2 = open(TESTFN)
+ fp1 = open(test_support.TESTFN)
+ fp2 = open(test_support.TESTFN)
try:
posix.dup2(fp1.fileno(), fp2.fileno())
finally:
@@ -84,7 +84,7 @@ class PosixTester(unittest.TestCase):
fp2.close()
def fdopen_helper(self, *args):
- fd = os.open(TESTFN, os.O_RDONLY)
+ fd = os.open(test_support.TESTFN, os.O_RDONLY)
fp2 = posix.fdopen(fd, *args)
fp2.close()
@@ -96,7 +96,7 @@ class PosixTester(unittest.TestCase):
def test_fstat(self):
if hasattr(posix, 'fstat'):
- fp = open(TESTFN)
+ fp = open(test_support.TESTFN)
try:
self.assert_(posix.fstat(fp.fileno()))
finally:
@@ -104,20 +104,20 @@ class PosixTester(unittest.TestCase):
def test_stat(self):
if hasattr(posix, 'stat'):
- self.assert_(posix.stat(TESTFN))
+ self.assert_(posix.stat(test_support.TESTFN))
def test_chdir(self):
if hasattr(posix, 'chdir'):
posix.chdir(os.curdir)
- self.assertRaises(OSError, posix.chdir, TESTFN)
+ self.assertRaises(OSError, posix.chdir, test_support.TESTFN)
def test_lsdir(self):
if hasattr(posix, 'lsdir'):
- self.assert_(TESTFN in posix.lsdir(os.curdir))
+ self.assert_(test_support.TESTFN in posix.lsdir(os.curdir))
def test_access(self):
if hasattr(posix, 'access'):
- self.assert_(posix.access(TESTFN, os.R_OK))
+ self.assert_(posix.access(test_support.TESTFN, os.R_OK))
def test_umask(self):
if hasattr(posix, 'umask'):
@@ -149,13 +149,11 @@ class PosixTester(unittest.TestCase):
def test_utime(self):
if hasattr(posix, 'utime'):
now = time.time()
- posix.utime(TESTFN, None)
- posix.utime(TESTFN, (now, now))
+ posix.utime(test_support.TESTFN, None)
+ posix.utime(test_support.TESTFN, (now, now))
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(PosixTester))
- run_suite(suite)
+ test_support.run_unittest(PosixTester)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py
index 83696db..2c86b09 100644
--- a/Lib/test/test_pow.py
+++ b/Lib/test/test_pow.py
@@ -103,9 +103,7 @@ class PowTest(unittest.TestCase):
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(PowTest))
- test.test_support.run_suite(suite)
+ test.test_support.run_unittest(PowTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_profilehooks.py
index 75599d9..ac8ebd8 100644
--- a/Lib/test/test_profilehooks.py
+++ b/Lib/test/test_profilehooks.py
@@ -349,11 +349,10 @@ def show_events(callable):
def test_main():
- loader = unittest.TestLoader()
- suite = unittest.TestSuite()
- suite.addTest(loader.loadTestsFromTestCase(ProfileHookTestCase))
- suite.addTest(loader.loadTestsFromTestCase(ProfileSimulatorTestCase))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ ProfileHookTestCase,
+ ProfileSimulatorTestCase
+ )
if __name__ == "__main__":
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index 9200043..bb07c2b 100644
--- a/Lib/test/test_pwd.py
+++ b/Lib/test/test_pwd.py
@@ -86,9 +86,7 @@ class PwdTest(unittest.TestCase):
self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(PwdTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(PwdTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 6eebedf..c0d51d9 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_suite
+from test.test_support import verbose, run_unittest
import re
from sre import Scanner
import sys, os, traceback
@@ -432,9 +432,7 @@ def run_re_tests():
print '=== Fails on unicode-sensitive match', t
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(ReTests))
- run_suite(suite)
+ run_unittest(ReTests)
run_re_tests()
if __name__ == "__main__":
diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py
index b4fc2ea..5ade8ed 100644
--- a/Lib/test/test_richcmp.py
+++ b/Lib/test/test_richcmp.py
@@ -352,7 +352,7 @@ class ListTest(unittest.TestCase):
self.assertIs(op(x, y), True)
def test_main():
- test_support.run_classtests(VectorTest, NumberTest, MiscTest, DictTest, ListTest)
+ test_support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_sets.py b/Lib/test/test_sets.py
index d5c886a..5b9c4e0 100644
--- a/Lib/test/test_sets.py
+++ b/Lib/test/test_sets.py
@@ -658,42 +658,34 @@ Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin', 'Sam', 'Zack'])
#==============================================================================
-def makeAllTests():
- suite = unittest.TestSuite()
- for klass in (TestSetOfSets,
- TestExceptionPropagation,
- TestBasicOpsEmpty,
- TestBasicOpsSingleton,
- TestBasicOpsTuple,
- TestBasicOpsTriple,
- TestBinaryOps,
- TestUpdateOps,
- TestMutate,
- TestSubsetEqualEmpty,
- TestSubsetEqualNonEmpty,
- TestSubsetEmptyNonEmpty,
- TestSubsetPartial,
- TestSubsetNonOverlap,
- TestOnlySetsNumeric,
- TestOnlySetsDict,
- TestOnlySetsOperator,
- TestCopyingEmpty,
- TestCopyingSingleton,
- TestCopyingTriple,
- TestCopyingTuple,
- TestCopyingNested,
- ):
- suite.addTest(unittest.makeSuite(klass))
- return suite
-
-#------------------------------------------------------------------------------
-
__test__ = {'libreftest' : libreftest}
def test_main(verbose=None):
from test import test_sets
- suite = makeAllTests()
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ TestSetOfSets,
+ TestExceptionPropagation,
+ TestBasicOpsEmpty,
+ TestBasicOpsSingleton,
+ TestBasicOpsTuple,
+ TestBasicOpsTriple,
+ TestBinaryOps,
+ TestUpdateOps,
+ TestMutate,
+ TestSubsetEqualEmpty,
+ TestSubsetEqualNonEmpty,
+ TestSubsetEmptyNonEmpty,
+ TestSubsetPartial,
+ TestSubsetNonOverlap,
+ TestOnlySetsNumeric,
+ TestOnlySetsDict,
+ TestOnlySetsOperator,
+ TestCopyingEmpty,
+ TestCopyingSingleton,
+ TestCopyingTriple,
+ TestCopyingTuple,
+ TestCopyingNested
+ )
test_support.run_doctest(test_sets, verbose)
if __name__ == "__main__":
diff --git a/Lib/test/test_shelve.py b/Lib/test/test_shelve.py
index a0274d5..8ef511e 100644
--- a/Lib/test/test_shelve.py
+++ b/Lib/test/test_shelve.py
@@ -121,15 +121,15 @@ class TestProto2MemShelve(TestShelveBase):
_in_mem = True
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestAsciiFileShelve))
- suite.addTest(unittest.makeSuite(TestBinaryFileShelve))
- suite.addTest(unittest.makeSuite(TestProto2FileShelve))
- suite.addTest(unittest.makeSuite(TestAsciiMemShelve))
- suite.addTest(unittest.makeSuite(TestBinaryMemShelve))
- suite.addTest(unittest.makeSuite(TestProto2MemShelve))
- suite.addTest(unittest.makeSuite(TestCase))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ TestAsciiFileShelve,
+ TestBinaryFileShelve,
+ TestProto2FileShelve,
+ TestAsciiMemShelve,
+ TestBinaryMemShelve,
+ TestProto2MemShelve,
+ TestCase
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index cd2469a..3a39ec9 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -14,15 +14,9 @@ class TestShutil(unittest.TestCase):
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestShutil))
- return suite
-
-
def test_main():
- test_support.run_suite(suite())
+ test_support.run_unittest(TestShutil)
if __name__ == '__main__':
- unittest.main(defaultTest='suite')
+ test_main()
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 279fd90..b9650e7 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -683,17 +683,18 @@ class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase):
bufsize = 2 # Exercise the buffering code
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(GeneralModuleTests))
- suite.addTest(unittest.makeSuite(BasicTCPTest))
+ tests = [ GeneralModuleTests, BasicTCPTest ]
if sys.platform != 'mac':
- suite.addTest(unittest.makeSuite(BasicUDPTest))
- suite.addTest(unittest.makeSuite(NonBlockingTCPTests))
- suite.addTest(unittest.makeSuite(FileObjectClassTestCase))
- suite.addTest(unittest.makeSuite(UnbufferedFileObjectClassTestCase))
- suite.addTest(unittest.makeSuite(LineBufferedFileObjectClassTestCase))
- suite.addTest(unittest.makeSuite(SmallBufferedFileObjectClassTestCase))
- test_support.run_suite(suite)
+ tests.append(BasicUDPTest)
+
+ tests.extend([
+ NonBlockingTCPTests,
+ FileObjectClassTestCase,
+ UnbufferedFileObjectClassTestCase,
+ LineBufferedFileObjectClassTestCase,
+ SmallBufferedFileObjectClassTestCase
+ ])
+ test_support.run_unittest(*tests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py
index b9f4845..1295a8c 100644
--- a/Lib/test/test_str.py
+++ b/Lib/test/test_str.py
@@ -19,9 +19,7 @@ class StrTest(
self.assertRaises(OverflowError, '%c'.__mod__, 0x1234)
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(StrTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(StrTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py
index 918207a..859dd4e 100644
--- a/Lib/test/test_string.py
+++ b/Lib/test/test_string.py
@@ -95,10 +95,7 @@ class ModuleTest(unittest.TestCase):
self.assertEqual(string.capwords('ABC-def DEF-ghi GHI'), 'Abc-def Def-ghi Ghi')
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(StringTest))
- suite.addTest(unittest.makeSuite(ModuleTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(StringTest, ModuleTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 2c3955b..140b226 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -406,14 +406,14 @@ class CalculationTests(unittest.TestCase):
"%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(LocaleTime_Tests))
- suite.addTest(unittest.makeSuite(TimeRETests))
- suite.addTest(unittest.makeSuite(StrptimeTests))
- suite.addTest(unittest.makeSuite(Strptime12AMPMTests))
- suite.addTest(unittest.makeSuite(JulianTests))
- suite.addTest(unittest.makeSuite(CalculationTests))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ LocaleTime_Tests,
+ TimeRETests,
+ StrptimeTests,
+ Strptime12AMPMTests,
+ JulianTests,
+ CalculationTests
+ )
if __name__ == '__main__':
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 56b60cc..906ed8a 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -229,15 +229,16 @@ def run_suite(suite, testclass=None):
raise TestFailed(err)
-def run_unittest(testclass):
- """Run tests from a unittest.TestCase-derived class."""
- run_suite(unittest.makeSuite(testclass), testclass)
-
-def run_classtests(*classnames):
+def run_unittest(*classes):
+ """Run tests from unittest.TestCase-derived classes."""
suite = unittest.TestSuite()
- for cls in classnames:
+ for cls in classes:
suite.addTest(unittest.makeSuite(cls))
- run_suite(suite)
+ if len(classes)==1:
+ testclass = classes[0]
+ else:
+ testclass = None
+ run_suite(suite, testclass)
#=======================================================================
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index feef540..0e61c6f 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -247,9 +247,7 @@ class SysModuleTest(unittest.TestCase):
self.assert_(isinstance(vi[4], int))
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(SysModuleTest))
- test.test_support.run_suite(suite)
+ test.test_support.run_unittest(SysModuleTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 584b7b3..496dede 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -240,27 +240,26 @@ def test_main():
# create testtar.tar.bz2
bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read())
- try:
- suite = unittest.TestSuite()
-
- suite.addTest(unittest.makeSuite(ReadTest))
- suite.addTest(unittest.makeSuite(ReadStreamTest))
- suite.addTest(unittest.makeSuite(WriteTest))
- suite.addTest(unittest.makeSuite(WriteStreamTest))
-
- if gzip:
- suite.addTest(unittest.makeSuite(ReadTestGzip))
- suite.addTest(unittest.makeSuite(ReadStreamTestGzip))
- suite.addTest(unittest.makeSuite(WriteTestGzip))
- suite.addTest(unittest.makeSuite(WriteStreamTestGzip))
+ tests = [
+ ReadTest,
+ ReadStreamTest,
+ WriteTest,
+ WriteStreamTest
+ ]
- if bz2:
- suite.addTest(unittest.makeSuite(ReadTestBzip2))
- suite.addTest(unittest.makeSuite(ReadStreamTestBzip2))
- suite.addTest(unittest.makeSuite(WriteTestBzip2))
- suite.addTest(unittest.makeSuite(WriteStreamTestBzip2))
+ if gzip:
+ tests.extend([
+ ReadTestGzip, ReadStreamTestGzip,
+ WriteTestGzip, WriteStreamTestGzip
+ ])
- test_support.run_suite(suite)
+ if bz2:
+ tests.extend([
+ ReadTestBzip2, ReadStreamTestBzip2,
+ WriteTestBzip2, WriteStreamTestBzip2
+ ])
+ try:
+ test_support.run_unittest(*tests)
finally:
if gzip:
os.remove(tarname("gz"))
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 09b9a10..8df3856 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -645,10 +645,7 @@ if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile:
test_classes.append(test_TemporaryFile)
def test_main():
- suite = unittest.TestSuite()
- for c in test_classes:
- suite.addTest(unittest.makeSuite(c))
- test_support.run_suite(suite)
+ test_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 b1cee30..b8964dc 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -352,11 +352,7 @@ some (including a hanging indent).'''
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(WrapTestCase))
- suite.addTest(unittest.makeSuite(LongWordTestCase))
- suite.addTest(unittest.makeSuite(IndentTestCases))
- test_support.run_suite(suite)
+ test_support.run_unittest(WrapTestCase, LongWordTestCase, IndentTestCases)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py
index d68484e..c0e1b13 100644
--- a/Lib/test/test_timeout.py
+++ b/Lib/test/test_timeout.py
@@ -186,10 +186,7 @@ class TimeoutTestCase(unittest.TestCase):
def test_main():
test_support.requires('network')
-
- suite = unittest.makeSuite(CreationTestCase)
- suite.addTest(unittest.makeSuite(TimeoutTestCase))
- test_support.run_suite(suite)
+ test_support.run_unittest(CreationTestCase, TimeoutTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 21e5ca9..ff6fc58 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -531,9 +531,11 @@ class JumpTestCase(unittest.TestCase):
no_jump_without_trace_function()
def test_main():
- test_support.run_unittest(TraceTestCase)
- test_support.run_unittest(RaisingTraceFuncTestCase)
- test_support.run_unittest(JumpTestCase)
+ test_support.run_unittest(
+ TraceTestCase,
+ RaisingTraceFuncTestCase,
+ JumpTestCase
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py
index d1fa35b..775044b 100644
--- a/Lib/test/test_ucn.py
+++ b/Lib/test/test_ucn.py
@@ -138,9 +138,7 @@ class UnicodeNamesTest(unittest.TestCase):
)
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(UnicodeNamesTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(UnicodeNamesTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 28837b4..9250ef2 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -698,9 +698,7 @@ class UnicodeTest(
print >>out, u'def\n'
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(UnicodeTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(UnicodeTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
index a3a5fbc..61b4ffb 100644
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -203,11 +203,11 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
self.assert_(count >= 10) # should have tested at least the ASCII digits
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(UnicodeMiscTest))
- suite.addTest(unittest.makeSuite(UnicodeMethodsTest))
- suite.addTest(unittest.makeSuite(UnicodeFunctionsTest))
- test.test_support.run_suite(suite)
+ test.test_support.run_unittest(
+ UnicodeMiscTest,
+ UnicodeMethodsTest,
+ UnicodeFunctionsTest
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py
index 8d89936..a6c079b 100644
--- a/Lib/test/test_univnewlines.py
+++ b/Lib/test/test_univnewlines.py
@@ -111,11 +111,13 @@ class TestMixedNewlines(TestGenericUnivNewlines):
def test_main():
- test_support.run_unittest(TestNativeNewlines)
- test_support.run_unittest(TestCRNewlines)
- test_support.run_unittest(TestLFNewlines)
- test_support.run_unittest(TestCRLFNewlines)
- test_support.run_unittest(TestMixedNewlines)
+ test_support.run_unittest(
+ TestNativeNewlines,
+ TestCRNewlines,
+ TestLFNewlines,
+ TestCRLFNewlines,
+ TestMixedNewlines
+ )
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index bc87b34..6afbe2f 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -408,14 +408,14 @@ class Pathname_Tests(unittest.TestCase):
def test_main():
- test_suite = unittest.TestSuite()
- test_suite.addTest(unittest.makeSuite(urlopen_FileTests))
- test_suite.addTest(unittest.makeSuite(urlretrieve_FileTests))
- test_suite.addTest(unittest.makeSuite(QuotingTests))
- test_suite.addTest(unittest.makeSuite(UnquotingTests))
- test_suite.addTest(unittest.makeSuite(urlencode_Tests))
- test_suite.addTest(unittest.makeSuite(Pathname_Tests))
- test_support.run_suite(test_suite)
+ test_support.run_unittest(
+ urlopen_FileTests,
+ urlretrieve_FileTests,
+ QuotingTests,
+ UnquotingTests,
+ urlencode_Tests,
+ Pathname_Tests
+ )
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index 3af2491..03728e1 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -23,10 +23,7 @@ class URLTimeoutTest(unittest.TestCase):
def test_main():
test_support.requires('network')
-
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(URLTimeoutTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(URLTimeoutTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py
index cbd3bd1..bcf60a5 100644
--- a/Lib/test/test_userdict.py
+++ b/Lib/test/test_userdict.py
@@ -395,11 +395,11 @@ class UserDictMixinTest(TestMappingProtocol):
self.assertEqual(s, t)
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestMappingProtocol))
- suite.addTest(unittest.makeSuite(UserDictTest))
- suite.addTest(unittest.makeSuite(UserDictMixinTest))
- test.test_support.run_suite(suite)
+ test.test_support.run_unittest(
+ TestMappingProtocol,
+ UserDictTest,
+ UserDictMixinTest
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py
index aec4b80..467a47c 100644
--- a/Lib/test/test_userlist.py
+++ b/Lib/test/test_userlist.py
@@ -252,9 +252,7 @@ class UserListTest(unittest.TestCase):
self.assertEqual(u, [0, 1, 0, 1, 0, 1])
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(UserListTest))
- test.test_support.run_suite(suite)
+ test.test_support.run_unittest(UserListTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index a821456..990199e 100755
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -44,9 +44,7 @@ class UserStringTest(
getattr(object, methodname)(*args)
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(UserStringTest))
- test_support.run_suite(suite)
+ test_support.run_unittest(UserStringTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index b078b17..eb87720 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -534,12 +534,12 @@ class WeakKeyDictionaryTestCase(TestMappingProtocol):
return self.__ref.copy()
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(ReferencesTestCase))
- suite.addTest(unittest.makeSuite(MappingTestCase))
- suite.addTest(unittest.makeSuite(WeakValueDictionaryTestCase))
- suite.addTest(unittest.makeSuite(WeakKeyDictionaryTestCase))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ ReferencesTestCase,
+ MappingTestCase,
+ WeakValueDictionaryTestCase,
+ WeakKeyDictionaryTestCase
+ )
if __name__ == "__main__":
diff --git a/Lib/test/test_xpickle.py b/Lib/test/test_xpickle.py
index cc458ad..42cd0f4 100644
--- a/Lib/test/test_xpickle.py
+++ b/Lib/test/test_xpickle.py
@@ -35,12 +35,10 @@ class DumpPickle_LoadCPickle(AbstractPickleTests):
return cPickle.loads(buf)
def test_main():
- suite = unittest.TestSuite()
- for test in (DumpCPickle_LoadPickle,
- DumpPickle_LoadCPickle,
- ):
- suite.addTest(unittest.makeSuite(test))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ DumpCPickle_LoadPickle,
+ DumpPickle_LoadCPickle
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 894b132..04682db 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -187,8 +187,10 @@ class CompressedZipImportTestCase(UncompressedZipImportTestCase):
def test_main():
- test_support.run_unittest(UncompressedZipImportTestCase)
- test_support.run_unittest(CompressedZipImportTestCase)
+ test_support.run_unittest(
+ UncompressedZipImportTestCase,
+ CompressedZipImportTestCase
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 686bc4c..c703964 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -479,24 +479,24 @@ LAERTES
def test_main():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(ChecksumTestCase))
- suite.addTest(unittest.makeSuite(ExceptionTestCase))
- suite.addTest(unittest.makeSuite(CompressTestCase))
- suite.addTest(unittest.makeSuite(CompressObjectTestCase))
- test_support.run_suite(suite)
+ test_support.run_unittest(
+ ChecksumTestCase,
+ ExceptionTestCase,
+ CompressTestCase,
+ CompressObjectTestCase
+ )
if __name__ == "__main__":
test_main()
def test(tests=''):
if not tests: tests = 'o'
- suite = unittest.TestSuite()
- if 'k' in tests: suite.addTest(unittest.makeSuite(ChecksumTestCase))
- if 'x' in tests: suite.addTest(unittest.makeSuite(ExceptionTestCase))
- if 'c' in tests: suite.addTest(unittest.makeSuite(CompressTestCase))
- if 'o' in tests: suite.addTest(unittest.makeSuite(CompressObjectTestCase))
- test_support.run_suite(suite)
+ testcases = []
+ if 'k' in tests: testcases.append(ChecksumTestCase)
+ if 'x' in tests: testcases.append(ExceptionTestCase)
+ if 'c' in tests: testcases.append(CompressTestCase)
+ if 'o' in tests: testcases.append(CompressObjectTestCase)
+ test_support.run_unittest(*testcases)
if False:
import sys