Skip to content

Commit 93ee219

Browse files
author
doerwalter
committed
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. git-svn-id: http://svn.python.org/projects/python/trunk@32570 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 520bc0f commit 93ee219

63 files changed

Lines changed: 309 additions & 401 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Lib/test/test_StringIO.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ class TestBuffercStringIO(TestcStringIO):
105105

106106

107107
def test_main():
108-
test_support.run_unittest(TestStringIO)
109-
test_support.run_unittest(TestcStringIO)
110-
test_support.run_unittest(TestBufferStringIO)
111-
test_support.run_unittest(TestBuffercStringIO)
108+
test_support.run_unittest(
109+
TestStringIO,
110+
TestcStringIO,
111+
TestBufferStringIO,
112+
TestBuffercStringIO
113+
)
112114

113115
if __name__ == '__main__':
114116
test_main()

Lib/test/test___all__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ def test_all(self):
192192

193193

194194
def test_main():
195-
suite = unittest.TestSuite()
196-
suite.addTest(unittest.makeSuite(AllTest))
197-
test_support.run_suite(suite)
195+
test_support.run_unittest(AllTest)
198196

199197
if __name__ == "__main__":
200198
test_main()

Lib/test/test_base64.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
from unittest import TestCase
2-
from test.test_support import vereq, run_unittest
3-
from base64 import encodestring, decodestring
1+
import unittest
2+
from test import test_support
3+
import base64
44

5-
class Base64TestCase(TestCase):
5+
class Base64TestCase(unittest.TestCase):
66

77
def test_encodestring(self):
8-
vereq(encodestring("www.python.org"), "d3d3LnB5dGhvbi5vcmc=\n")
9-
vereq(encodestring("a"), "YQ==\n")
10-
vereq(encodestring("ab"), "YWI=\n")
11-
vereq(encodestring("abc"), "YWJj\n")
12-
vereq(encodestring(""), "")
13-
vereq(encodestring("abcdefghijklmnopqrstuvwxyz"
8+
self.assertEqual(base64.encodestring("www.python.org"), "d3d3LnB5dGhvbi5vcmc=\n")
9+
self.assertEqual(base64.encodestring("a"), "YQ==\n")
10+
self.assertEqual(base64.encodestring("ab"), "YWI=\n")
11+
self.assertEqual(base64.encodestring("abc"), "YWJj\n")
12+
self.assertEqual(base64.encodestring(""), "")
13+
self.assertEqual(base64.encodestring("abcdefghijklmnopqrstuvwxyz"
1414
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1515
"0123456789!@#0^&*();:<>,. []{}"),
1616
"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
1717
"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
1818
"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n")
1919

2020
def test_decodestring(self):
21-
vereq(decodestring("d3d3LnB5dGhvbi5vcmc=\n"), "www.python.org")
22-
vereq(decodestring("YQ==\n"), "a")
23-
vereq(decodestring("YWI=\n"), "ab")
24-
vereq(decodestring("YWJj\n"), "abc")
25-
vereq(decodestring("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
21+
self.assertEqual(base64.decodestring("d3d3LnB5dGhvbi5vcmc=\n"), "www.python.org")
22+
self.assertEqual(base64.decodestring("YQ==\n"), "a")
23+
self.assertEqual(base64.decodestring("YWI=\n"), "ab")
24+
self.assertEqual(base64.decodestring("YWJj\n"), "abc")
25+
self.assertEqual(base64.decodestring("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
2626
"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
2727
"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n"),
2828
"abcdefghijklmnopqrstuvwxyz"
2929
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3030
"0123456789!@#0^&*();:<>,. []{}")
31-
vereq(decodestring(''), '')
31+
self.assertEqual(base64.decodestring(''), '')
3232

3333
def test_main():
34-
run_unittest(Base64TestCase)
34+
test_support.run_unittest(Base64TestCase)
3535

3636
if __name__ == "__main__":
3737
test_main()

Lib/test/test_bisect.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ def test_backcompatibility(self):
198198

199199
def test_main(verbose=None):
200200
from test import test_bisect
201-
test_support.run_classtests(TestBisect,
202-
TestInsort)
201+
test_support.run_unittest(TestBisect, TestInsort)
203202
test_support.run_doctest(test_bisect, verbose)
204203

205204
if __name__ == "__main__":

Lib/test/test_bool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def test_picklevalues(self):
321321
self.assertEqual(cPickle.dumps(False, True), "I00\n.")
322322

323323
def test_main():
324-
test_support.run_classtests(BoolTest)
324+
test_support.run_unittest(BoolTest)
325325

326326
if __name__ == "__main__":
327327
test_main()

Lib/test/test_builtin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,9 +1219,7 @@ def __getitem__(self, i):
12191219
self.assertRaises(ValueError, zip, BadSeq(), BadSeq())
12201220

12211221
def test_main():
1222-
suite = unittest.TestSuite()
1223-
suite.addTest(unittest.makeSuite(BuiltinTest))
1224-
test.test_support.run_suite(suite)
1222+
test.test_support.run_unittest(BuiltinTest)
12251223

12261224
if __name__ == "__main__":
12271225
test_main()

Lib/test/test_bz2.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,12 @@ def testDecompressIncomplete(self):
309309
self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10])
310310

311311
def test_main():
312-
suite = unittest.TestSuite()
313-
for test in (BZ2FileTest,
314-
BZ2CompressorTest,
315-
BZ2DecompressorTest,
316-
FuncTest):
317-
suite.addTest(unittest.makeSuite(test))
318-
test_support.run_suite(suite)
312+
test_support.run_unittest(
313+
BZ2FileTest,
314+
BZ2CompressorTest,
315+
BZ2DecompressorTest,
316+
FuncTest
317+
)
319318

320319
if __name__ == '__main__':
321320
test_main()

Lib/test/test_calendar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import calendar
22
import unittest
33

4-
from test.test_support import run_unittest
4+
from test import test_support
55

66

77
class CalendarTestCase(unittest.TestCase):
@@ -55,7 +55,7 @@ def test_months(self):
5555
self.assertEqual(len(d), 13)
5656

5757
def test_main():
58-
run_unittest(CalendarTestCase)
58+
test_support.run_unittest(CalendarTestCase)
5959

6060
if __name__ == "__main__":
6161
test_main()

Lib/test/test_call.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import unittest
2-
from test.test_support import run_unittest
2+
from test import test_support
33

44
# The test cases here cover several paths through the function calling
55
# code. They depend on the METH_XXX flag that is used to define a C
@@ -124,7 +124,7 @@ def test_oldargs1_2_kw(self):
124124

125125

126126
def test_main():
127-
run_unittest(CFunctionCalls)
127+
test_support.run_unittest(CFunctionCalls)
128128

129129

130130
if __name__ == "__main__":

Lib/test/test_cfgparser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@ def test_safe_interpolation(self):
322322

323323

324324
def test_main():
325-
suite = unittest.TestSuite()
326-
suite.addTests([unittest.makeSuite(ConfigParserTestCase),
327-
unittest.makeSuite(RawConfigParserTestCase),
328-
unittest.makeSuite(SafeConfigParserTestCase)])
329-
test_support.run_suite(suite)
325+
test_support.run_unittest(
326+
ConfigParserTestCase,
327+
RawConfigParserTestCase,
328+
SafeConfigParserTestCase
329+
)
330330

331331
if __name__ == "__main__":
332332
test_main()

0 commit comments

Comments
 (0)