Issue #21741: Update 147 test modules to use test discovery.

I have compared output between pre- and post-patch runs of these tests
to make sure there's nothing missing and nothing broken, on both
Windows and Linux.  The only differences I found were actually tests
that were previously *not* run.
This commit is contained in:
Zachary Ware 2015-04-13 15:00:43 -05:00
parent 4b761bf79a
commit 38c707e7e0
148 changed files with 184 additions and 866 deletions

View File

@ -3885,8 +3885,5 @@ class Oddballs(unittest.TestCase):
with self.assertRaises(TypeError):
datetime(10, 10, 10, 10, 10, 10, 10.)
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,5 +1,4 @@
import unittest
from test import support
import __future__
GOOD_SERIALS = ("alpha", "beta", "candidate", "final")
@ -58,8 +57,5 @@ class FutureTest(unittest.TestCase):
".compiler_flag isn't int")
def test_main():
support.run_unittest(FutureTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,5 +1,5 @@
import dis
from test.support import run_unittest, import_module
from test.support import import_module
import unittest
_opcode = import_module("_opcode")
@ -16,8 +16,5 @@ class OpcodeTests(unittest.TestCase):
self.assertRaises(ValueError, _opcode.stack_effect, dis.opmap['BUILD_SLICE'])
self.assertRaises(ValueError, _opcode.stack_effect, dis.opmap['POP_TOP'], 0)
def test_main():
run_unittest(OpcodeTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -273,9 +273,5 @@ class Test_OSXSupport(unittest.TestCase):
result = _osx_support.get_platform_osx(config_vars, ' ', ' ', ' ')
self.assertEqual(('macosx', '10.6', 'fat'), result)
def test_main():
if sys.platform == 'darwin':
test.support.run_unittest(Test_OSXSupport)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -177,9 +177,5 @@ class SubinterpreterTest(unittest.TestCase):
self.assertEqual(atexit._ncallbacks(), n)
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,6 +1,5 @@
# Augmented assignment test.
from test.support import run_unittest
import unittest
@ -315,8 +314,5 @@ __rlshift__ called
__ilshift__ called
'''.splitlines())
def test_main():
run_unittest(AugAssignTest)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,6 +1,5 @@
"""Test the binascii C module."""
from test import support
import unittest
import binascii
import array
@ -262,11 +261,5 @@ class MemoryviewBinASCIITest(BinASCIITest):
type2test = memoryview
def test_main():
support.run_unittest(BinASCIITest,
ArrayBinASCIITest,
BytearrayBinASCIITest,
MemoryviewBinASCIITest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -369,8 +369,5 @@ class OperationOrderTests(unittest.TestCase):
self.assertEqual(op_sequence(le, B, C), ['C.__ge__', 'B.__le__'])
self.assertEqual(op_sequence(le, C, B), ['C.__le__', 'B.__ge__'])
def test_main():
support.run_unittest(RatTestCase, OperationOrderTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,5 +1,4 @@
import unittest
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
@ -123,9 +122,5 @@ class CFunctionCalls(unittest.TestCase):
self.assertRaises(TypeError, [].count, x=2, y=2)
def test_main():
support.run_unittest(CFunctionCalls)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,4 +1,3 @@
from test.support import run_unittest
from test.script_helper import assert_python_failure, temp_dir
import unittest
import sys
@ -63,8 +62,5 @@ class TestCgitb(unittest.TestCase):
self.assertNotIn('</p>', out)
def test_main():
run_unittest(TestCgitb)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -49,8 +49,5 @@ class CharmapCodecTest(unittest.TestCase):
def test_maptoundefined(self):
self.assertRaises(UnicodeError, str, b'abc\001', codecname)
def test_main():
test.support.run_unittest(CharmapCodecTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -2,7 +2,6 @@
import unittest
from test import support
testmeths = [
@ -569,8 +568,5 @@ class ClassTests(unittest.TestCase):
a = A(hash(A.f)^(-1))
hash(a.f)
def test_main():
support.run_unittest(ClassTests)
if __name__=='__main__':
test_main()
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from test.support import run_unittest, requires_IEEE_754
from test.support import requires_IEEE_754
from test.test_math import parse_testfile, test_file
import unittest
import cmath, math
@ -529,8 +529,5 @@ class CMathTests(unittest.TestCase):
self.assertComplexIdentical(cmath.atanh(z), z)
def test_main():
run_unittest(CMathTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -114,8 +114,5 @@ class TestInteractiveConsole(unittest.TestCase):
self.assertIn(expected, output)
def test_main():
support.run_unittest(TestInteractiveConsole)
if __name__ == "__main__":
unittest.main()

View File

@ -83,8 +83,5 @@ class Test_HZ(multibytecodec_support.TestBase, unittest.TestCase):
(b"ab~{\x79\x79\x41\x44~}cd", "replace", "ab\ufffd\ufffd\u804acd"),
)
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -19,8 +19,5 @@ class Test_Big5HKSCS(multibytecodec_support.TestBase, unittest.TestCase):
(b"abc\x80\x80\xc1\xc4", "ignore", "abc\u8b10"),
)
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -38,8 +38,5 @@ class Test_ISO2022_KR(multibytecodec_support.TestBase, unittest.TestCase):
def test_chunkcoding(self):
pass
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -123,8 +123,5 @@ class Test_SJISX0213(multibytecodec_support.TestBase, unittest.TestCase):
b"\x85G&real;\x85Q = &lang;&#4660;&rang;"
)
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -66,8 +66,5 @@ class Test_JOHAB(multibytecodec_support.TestBase, unittest.TestCase):
(b"\x8CBxy", "replace", "\uFFFDBxy"),
)
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -19,8 +19,5 @@ class Test_Big5(multibytecodec_support.TestBase, unittest.TestCase):
(b"abc\x80\x80\xc1\xc4", "ignore", "abc\u8b10"),
)
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -3,7 +3,7 @@
Nick Mathewson
"""
import unittest
from test.support import run_unittest, is_jython
from test.support import is_jython
from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT
import io
@ -296,9 +296,5 @@ class CodeopTests(unittest.TestCase):
compile("a = 1\n", "def", 'single').co_filename)
def test_main():
run_unittest(CodeopTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,5 +1,4 @@
import unittest
from test import support
class Empty:
def __repr__(self):
@ -121,8 +120,5 @@ class ComparisonTest(unittest.TestCase):
self.assertEqual(Anything(), y)
def test_main():
support.run_unittest(ComparisonTest)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,5 +1,4 @@
from collections import deque
from test.support import run_unittest
import unittest
@ -86,8 +85,5 @@ class TestContains(unittest.TestCase):
self.assertTrue(container == container)
def test_main():
run_unittest(TestContains)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -7,7 +7,6 @@ import abc
from operator import le, lt, ge, gt, eq, ne
import unittest
from test import support
order_comparisons = le, lt, ge, gt
equality_comparisons = eq, ne
@ -822,8 +821,5 @@ class TestCopy(unittest.TestCase):
def global_foo(x, y): return x+y
def test_main():
support.run_unittest(TestCopy)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,7 +1,6 @@
import copyreg
import unittest
from test import support
from test.pickletester import ExtensionSaver
class C:
@ -113,9 +112,5 @@ class CopyRegTestCase(unittest.TestCase):
self.assertEqual(result, expected)
def test_main():
support.run_unittest(CopyRegTestCase)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -30,9 +30,8 @@ class CrasherTest(unittest.TestCase):
assert_python_failure(fname)
def test_main():
test.support.run_unittest(CrasherTest)
def tearDownModule():
test.support.reap_children()
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1084,11 +1084,5 @@ class TestUnicode(unittest.TestCase):
self.assertEqual(fileobj.read(), expected)
def test_main():
mod = sys.modules[__name__]
support.run_unittest(
*[getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,5 +1,4 @@
import unittest
from test import support
def funcattrs(**kwds):
def decorate(func):
@ -301,9 +300,5 @@ class TestClassDecorators(unittest.TestCase):
class C(object): pass
self.assertEqual(C.extra, 'second')
def test_main():
support.run_unittest(TestDecorators)
support.run_unittest(TestClassDecorators)
if __name__=="__main__":
test_main()
if __name__ == "__main__":
unittest.main()

View File

@ -5,7 +5,6 @@ import copy
import pickle
import tempfile
import unittest
from test import support
from collections import defaultdict
@ -184,8 +183,5 @@ class TestDefaultDict(unittest.TestCase):
o = pickle.loads(s)
self.assertEqual(d, o)
def test_main():
support.run_unittest(TestDefaultDict)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -949,12 +949,5 @@ class Dict(dict):
class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol):
type2test = Dict
def test_main():
support.run_unittest(
DictTest,
GeneralMappingTests,
SubclassMappingTests,
)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,5 +1,4 @@
import unittest
from test import support
class DictSetTest(unittest.TestCase):
@ -199,8 +198,5 @@ class DictSetTest(unittest.TestCase):
self.assertRaises(RuntimeError, repr, d)
def test_main():
support.run_unittest(DictSetTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,6 +1,6 @@
# Minimal tests for dis module
from test.support import run_unittest, captured_stdout
from test.support import captured_stdout
from test.bytecode_helper import BytecodeTestCase
import difflib
import unittest

View File

@ -213,8 +213,5 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
response.read())
def test_main():
support.run_unittest(DocXMLRPCHTTPGETServer)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -56,9 +56,5 @@ class DummyThreadingTestCase(unittest.TestCase):
if support.verbose:
print('all tasks done')
def test_main():
support.run_unittest(DummyThreadingTestCase)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -4,7 +4,7 @@ import builtins
import contextlib
import unittest
from test.support import run_unittest, swap_item, swap_attr
from test.support import swap_item, swap_attr
class RebindBuiltinsTests(unittest.TestCase):
@ -135,9 +135,5 @@ class RebindBuiltinsTests(unittest.TestCase):
self.assertEqual(foo(), 7)
def test_main():
run_unittest(RebindBuiltinsTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -4,7 +4,6 @@
import abc
import sys
import unittest
from test.support import run_unittest
from types import DynamicClassAttribute
class PropertyBase(Exception):
@ -297,8 +296,5 @@ class PropertySubclassTests(unittest.TestCase):
def test_main():
run_unittest(PropertyTests, PropertySubclassTests)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -342,4 +342,4 @@ class TestUninstallationMainFunction(EnsurepipMixin, unittest.TestCase):
if __name__ == "__main__":
test.support.run_unittest(__name__)
unittest.main()

View File

@ -258,16 +258,5 @@ class TestLongStart(EnumerateStartTestCase):
(sys.maxsize+3,'c')]
def test_main(verbose=None):
support.run_unittest(__name__)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
counts = [None] * 5
for i in range(len(counts)):
support.run_unittest(__name__)
counts[i] = sys.gettotalrefcount()
print(counts)
if __name__ == "__main__":
test_main(verbose=True)
unittest.main()

View File

@ -24,8 +24,5 @@ class EOFTestCase(unittest.TestCase):
else:
raise support.TestFailed
def test_main():
support.run_unittest(EOFTestCase)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -252,8 +252,5 @@ class TestEPoll(unittest.TestCase):
self.assertEqual(os.get_inheritable(epoll.fileno()), False)
def test_main():
support.run_unittest(TestEPoll)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -3,7 +3,6 @@
"""
import errno
from test import support
import unittest
std_c_errors = frozenset(['EDOM', 'ERANGE'])
@ -32,9 +31,5 @@ class ErrorcodeTests(unittest.TestCase):
'no %s attr in errno.errorcode' % attribute)
def test_main():
support.run_unittest(ErrnoAttributeTests, ErrorcodeTests)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,5 +1,4 @@
from test.support import run_unittest
import unittest
class ExceptionTestCase(unittest.TestCase):
@ -173,8 +172,5 @@ class ExceptionTestCase(unittest.TestCase):
self.assertTrue(hit_finally)
self.assertTrue(hit_except)
def test_main():
run_unittest(ExceptionTestCase)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -13,7 +13,6 @@ import select
import signal
import subprocess
import sys
from test.support import run_unittest
import time
import unittest
@ -249,12 +248,5 @@ class PyTestTextIOSignalInterrupt(TestTextIOSignalInterrupt, unittest.TestCase):
modname = '_pyio'
def test_main():
test_cases = [
tc for tc in globals().values()
if isinstance(tc, type) and issubclass(tc, unittest.TestCase)]
run_unittest(*test_cases)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -515,8 +515,5 @@ class LegacyFinalizationTest(TestBase, unittest.TestCase):
self.assertIs(wr(), None)
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1299,18 +1299,5 @@ class HexFloatTestCase(unittest.TestCase):
self.identical(x, fromHex(toHex(x)))
def test_main():
support.run_unittest(
GeneralFloatCases,
FormatFunctionsTestCase,
UnknownFormatTestCase,
IEEEFormatTestCase,
FormatTestCase,
ReprTestCase,
RoundTestCase,
InfNanTest,
HexFloatTestCase,
)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -18,10 +18,5 @@ class FLUFLTests(unittest.TestCase):
'<FLUFL test>', 'exec')
def test_main():
from test.support import run_unittest
run_unittest(FLUFLTests)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,6 +1,5 @@
"""Test cases for the fnmatch module."""
from test import support
import unittest
from fnmatch import fnmatch, fnmatchcase, translate, filter
@ -79,11 +78,5 @@ class FilterTestCase(unittest.TestCase):
self.assertEqual(filter(['a', 'b'], 'a'), ['a'])
def test_main():
support.run_unittest(FnmatchTestCase,
TranslateTestCase,
FilterTestCase)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -8,7 +8,7 @@ import sys
import time
from test.fork_wait import ForkWait
from test.support import (run_unittest, reap_children, get_attribute,
from test.support import (reap_children, get_attribute,
import_module, verbose)
threading = import_module('threading')
@ -104,9 +104,8 @@ class ForkTest(ForkWait):
fork_with_import_lock(level)
def test_main():
run_unittest(ForkTest)
def tearDownModule():
reap_children()
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,7 +1,7 @@
"""Tests for Lib/fractions.py."""
from decimal import Decimal
from test.support import run_unittest, requires_IEEE_754
from test.support import requires_IEEE_754
import math
import numbers
import operator
@ -606,8 +606,5 @@ class FractionTest(unittest.TestCase):
r = F(13, 7)
self.assertRaises(AttributeError, setattr, r, 'a', 10)
def test_main():
run_unittest(FractionTest, GcdTest)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -161,8 +161,5 @@ class FrameLocalsTest(unittest.TestCase):
self.assertEqual(inner.f_locals, {})
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,4 +1,3 @@
from test import support
import types
import unittest
@ -374,12 +373,5 @@ class BuiltinFunctionPropertiesTest(unittest.TestCase):
self.assertEqual({'foo': 'bar'}.pop.__qualname__, 'dict.pop')
def test_main():
support.run_unittest(FunctionPropertiesTest, InstancemethodAttrTest,
ArbitraryFunctionAttrTest, FunctionDictsTest,
FunctionDocstringTest, CellTest,
StaticMethodAttrsTest,
BuiltinFunctionPropertiesTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1584,32 +1584,5 @@ class TestSingleDispatch(unittest.TestCase):
functools.WeakKeyDictionary = _orig_wkd
def test_main(verbose=None):
test_classes = (
TestPartialC,
TestPartialPy,
TestPartialCSubclass,
TestPartialMethod,
TestUpdateWrapper,
TestTotalOrdering,
TestCmpToKeyC,
TestCmpToKeyPy,
TestWraps,
TestReduce,
TestLRU,
TestSingleDispatch,
)
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)):
support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
if __name__ == '__main__':
test_main(verbose=True)
unittest.main()

View File

@ -1,7 +1,7 @@
# test_getopt.py
# David Goodger <dgoodger@bigfoot.com> 2000-08-19
from test.support import verbose, run_doctest, run_unittest, EnvironmentVarGuard
from test.support import verbose, run_doctest, EnvironmentVarGuard
import unittest
import getopt
@ -180,8 +180,5 @@ class GetoptTests(unittest.TestCase):
self.assertEqual(longopts, [('--help', 'x')])
self.assertRaises(getopt.GetoptError, getopt.getopt, ['--help='], '', ['help'])
def test_main():
run_unittest(GetoptTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,7 +1,7 @@
# Python test set -- part 1, grammar.
# This just tests whether the parser accepts them all.
from test.support import run_unittest, check_syntax_error
from test.support import check_syntax_error
import unittest
import sys
# testing import *
@ -1031,8 +1031,5 @@ class GrammarTests(unittest.TestCase):
self.assertEqual(m.other, 42)
def test_main():
run_unittest(TokenTests, GrammarTests)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -92,8 +92,5 @@ class GroupDatabaseTestCase(unittest.TestCase):
self.assertRaises(KeyError, grp.getgrgid, fakegid)
def test_main():
support.run_unittest(GroupDatabaseTestCase)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -493,14 +493,5 @@ class CompareDigestTestCase(unittest.TestCase):
self.assertFalse(hmac.compare_digest(a, b))
def test_main():
support.run_unittest(
TestVectorsTestCase,
ConstructorTestCase,
SanityTestCase,
CopyTestCase,
CompareDigestTestCase
)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -4,7 +4,6 @@ Tests for the html module functions.
import html
import unittest
from test.support import run_unittest
class HtmlTests(unittest.TestCase):

View File

@ -451,8 +451,5 @@ class IntTestCases(unittest.TestCase):
check('123\ud800')
check('123\ud800', 10)
def test_main():
support.run_unittest(IntTestCases)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -4,7 +4,6 @@ This is complex because of changes due to PEP 237.
"""
import unittest
from test import support
class TestHexOctBin(unittest.TestCase):
@ -140,8 +139,5 @@ class TestHexOctBin(unittest.TestCase):
self.assertEqual(-0b1000000000000000000000000000000000000000000000000000000000000000, -9223372036854775808)
self.assertEqual(-0b1111111111111111111111111111111111111111111111111111111111111111, -18446744073709551615)
def test_main():
support.run_unittest(TestHexOctBin)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,6 +1,6 @@
import array
import unittest
from test.support import run_unittest, import_module, get_attribute
from test.support import import_module, get_attribute
import os, struct
fcntl = import_module('fcntl')
termios = import_module('termios')

View File

@ -3,7 +3,6 @@
# testing of error conditions uncovered when using extension types.
import unittest
from test import support
import sys
@ -277,13 +276,5 @@ def blowstack(fxn, arg, compare_to):
fxn(arg, tuple_arg)
def test_main():
support.run_unittest(
TestIsInstanceExceptions,
TestIsSubclassExceptions,
TestIsInstanceIsSubclass
)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -4,7 +4,6 @@ __author__ = "Jiwon Seo"
__email__ = "seojiwon at gmail dot com"
import unittest
from test.support import run_unittest
def posonly_sum(pos_arg1, *arg, **kwarg):
return pos_arg1 + sum(arg) + sum(kwarg.values())
@ -186,8 +185,5 @@ class KeywordOnlyArgTestCase(unittest.TestCase):
self.assertEqual(str(err.exception), "name 'b' is not defined")
def test_main():
run_unittest(KeywordOnlyArgTestCase)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -9,7 +9,6 @@ import sys
import time
import unittest
from test import support
if not hasattr(select, "kqueue"):
raise unittest.SkipTest("test works only on BSD")
@ -237,8 +236,5 @@ class TestKQueue(unittest.TestCase):
self.assertEqual(os.get_inheritable(kqueue.fileno()), False)
def test_main():
support.run_unittest(TestKQueue)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -108,20 +108,5 @@ class ListTest(list_tests.CommonTest):
with self.assertRaises(TypeError):
(3,) + L([1,2])
def test_main(verbose=None):
support.run_unittest(ListTest)
# verify reference counting
import sys
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
support.run_unittest(ListTest)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
if __name__ == "__main__":
test_main(verbose=True)
unittest.main()

View File

@ -1241,8 +1241,5 @@ class LongTest(unittest.TestCase):
self.assertEqual(type(value >> shift), int)
def test_main():
support.run_unittest(LongTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,5 +1,4 @@
import unittest
from test import support
class LongExpText(unittest.TestCase):
def test_longexp(self):
@ -7,8 +6,5 @@ class LongExpText(unittest.TestCase):
l = eval("[" + "2," * REPS + "]")
self.assertEqual(len(l), REPS)
def test_main():
support.run_unittest(LongExpText)
if __name__=="__main__":
test_main()
if __name__ == "__main__":
unittest.main()

View File

@ -213,9 +213,5 @@ class FindmatchTest(unittest.TestCase):
self.assertEqual(mailcap.findmatch(*c[0], **c[1]), c[2])
def test_main():
test.support.run_unittest(HelperFunctionTest, GetcapsTest, FindmatchTest)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -826,10 +826,5 @@ class CStringIOPickleTest(PyStringIOPickleTest):
pass
def test_main():
tests = [PyBytesIOTest, PyStringIOTest, CBytesIOTest, CStringIOTest,
PyStringIOPickleTest, CStringIOPickleTest]
support.run_unittest(*tests)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -492,8 +492,5 @@ class ArrayMemorySliceSliceTest(unittest.TestCase,
pass
def test_main():
test.support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -101,11 +101,5 @@ class Win32MimeTypesTestCase(unittest.TestCase):
eq(self.db.guess_type("image.jpg"), ("image/jpeg", None))
eq(self.db.guess_type("image.png"), ("image/png", None))
def test_main():
support.run_unittest(MimeTypesTestCase,
Win32MimeTypesTestCase
)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,7 +1,7 @@
# test for xml.dom.minidom
import pickle
from test.support import run_unittest, findfile
from test.support import findfile
import unittest
import xml.dom.minidom
@ -1545,8 +1545,5 @@ class MinidomTest(unittest.TestCase):
pi = doc.createProcessingInstruction("y", "z")
pi.nodeValue = "crash"
def test_main():
run_unittest(MinidomTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,7 +1,7 @@
# Test the module type
import unittest
import weakref
from test.support import run_unittest, gc_collect
from test.support import gc_collect
from test.script_helper import assert_python_ok
import sys
@ -238,9 +238,5 @@ a = A(destroyed)"""
# frozen and namespace module reprs are tested in importlib.
def test_main():
run_unittest(ModuleTests)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,7 +1,7 @@
""" Test suite for the code in msilib """
import unittest
import os
from test.support import run_unittest, import_module
from test.support import import_module
msilib = import_module('msilib')
class Test_make_id(unittest.TestCase):
@ -39,8 +39,5 @@ class Test_make_id(unittest.TestCase):
msilib.make_id(".s\x82o?*+rt"), "_.s_o___rt")
def test_main():
run_unittest(__name__)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -36,8 +36,5 @@ class NisTests(unittest.TestCase):
if done:
break
def test_main():
support.run_unittest(NisTests)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,4 +1,4 @@
from test.support import run_unittest, open_urlresource
from test.support import open_urlresource
import unittest
from http.client import HTTPException
@ -97,8 +97,5 @@ class NormalizationTest(unittest.TestCase):
normalize('NFC', '\ud55c\uae00')
def test_main():
run_unittest(NormalizationTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -5,7 +5,6 @@ import random
import math
import sys
import operator
from test.support import run_unittest
from decimal import Decimal as D
from fractions import Fraction as F
@ -199,8 +198,5 @@ class ComparisonTest(unittest.TestCase):
self.assertRaises(TypeError, op, v, z)
def test_main():
run_unittest(HashTest, ComparisonTest)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,6 +1,5 @@
# Python test set -- part 2, opcodes
from test.support import run_unittest
import unittest
class OpcodeTest(unittest.TestCase):
@ -105,8 +104,5 @@ class OpcodeTest(unittest.TestCase):
self.assertEqual(MyString() % 3, 42)
def test_main():
run_unittest(OpcodeTest)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,7 +1,6 @@
# Test to see if openpty works. (But don't worry if it isn't available.)
import os, unittest
from test.support import run_unittest
if not hasattr(os, "openpty"):
raise unittest.SkipTest("os.openpty() not available.")
@ -18,8 +17,5 @@ class OpenptyTest(unittest.TestCase):
os.write(slave, b'Ping!')
self.assertEqual(os.read(master, 1024), b'Ping!')
def test_main():
run_unittest(OpenptyTest)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -2,7 +2,7 @@
Test suite for OS X interpreter environment variables.
"""
from test.support import EnvironmentVarGuard, run_unittest
from test.support import EnvironmentVarGuard
import subprocess
import sys
import sysconfig

View File

@ -730,16 +730,5 @@ class OtherParserCase(unittest.TestCase):
with self.assertRaises(TypeError):
parser.expr("a", "b")
def test_main():
support.run_unittest(
RoundtripLegalSyntaxTestCase,
IllegalSyntaxTestCase,
CompileTestCase,
ParserStackLimitTestCase,
STObjectTestCase,
OtherParserCase,
)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -319,21 +319,5 @@ class TestBuglets(unittest.TestCase):
f()
def test_main(verbose=None):
import sys
from test import support
test_classes = (TestTranforms, TestBuglets)
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)):
support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
if __name__ == "__main__":
test_main(verbose=True)
unittest.main()

View File

@ -6,7 +6,6 @@ for hashing algorithms
import hmac
import unittest
from hashlib import md5, sha1, sha224, sha256, sha384, sha512
from test import support
class Pep247Test(unittest.TestCase):
@ -63,8 +62,5 @@ class Pep247Test(unittest.TestCase):
def test_hmac(self):
self.check_module(hmac, key=b'abc')
def test_main():
support.run_unittest(Pep247Test)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -244,11 +244,5 @@ class TestTemplate(unittest.TestCase):
'tim likes to eat a bag of ham worth $100')
def test_main():
from test import support
test_classes = [TestTemplate,]
support.run_unittest(*test_classes)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -1,7 +1,6 @@
# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
import unittest
from test import support
class PEP3120Test(unittest.TestCase):
@ -40,8 +39,5 @@ class BuiltinCompileTests(unittest.TestCase):
self.assertEqual('Ç', ns['u'])
def test_main():
support.run_unittest(PEP3120Test, BuiltinCompileTests)
if __name__=="__main__":
test_main()
if __name__ == "__main__":
unittest.main()

View File

@ -1,6 +1,5 @@
import unittest
import sys
from test import support
class PEP3131Test(unittest.TestCase):
@ -28,8 +27,5 @@ class PEP3131Test(unittest.TestCase):
else:
self.fail("expected exception didn't occur")
def test_main():
support.run_unittest(PEP3131Test)
if __name__=="__main__":
test_main()
if __name__ == "__main__":
unittest.main()

View File

@ -7,7 +7,6 @@ import unittest
import errno
from errno import EEXIST
from test import support
class SubOSError(OSError):
pass
@ -202,8 +201,5 @@ class ExplicitSubclassingTest(unittest.TestCase):
self.assertEqual(str(e), '')
def test_main():
support.run_unittest(__name__)
if __name__=="__main__":
test_main()
if __name__ == "__main__":
unittest.main()

View File

@ -1013,11 +1013,5 @@ class TestPEP380Operation(unittest.TestCase):
self.assertEqual(v, (1, 2, 3, 4))
def test_main():
from test import support
test_classes = [TestPEP380Operation]
support.run_unittest(*test_classes)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -291,9 +291,5 @@ class TestPkg(unittest.TestCase):
import t8
self.assertEqual(t8.__doc__, "doc for t8")
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -7,7 +7,7 @@ import tempfile
import unittest
from importlib.util import cache_from_source
from test.support import run_unittest, create_empty_file
from test.support import create_empty_file
class TestImport(unittest.TestCase):
@ -76,9 +76,5 @@ class TestImport(unittest.TestCase):
self.assertEqual(getattr(module, var), 1)
def test_main():
run_unittest(TestImport)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -57,8 +57,5 @@ class PopenTest(unittest.TestCase):
with os.popen("echo hello") as f:
self.assertEqual(list(f), ["hello\n"])
def test_main():
support.run_unittest(PopenTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -122,8 +122,5 @@ class PowTest(unittest.TestCase):
eq(pow(a, -fiveto), expected)
eq(expected, 1.0) # else we didn't push fiveto to evenness
def test_main():
test.support.run_unittest(PowTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -3,7 +3,6 @@
import sys
import unittest
from test.support import run_unittest
class PropertyBase(Exception):
pass
@ -247,8 +246,5 @@ class PropertySubclassTests(unittest.TestCase):
def test_main():
run_unittest(PropertyTests, PropertySubclassTests)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -34,12 +34,5 @@ class StatsTestCase(unittest.TestCase):
stats.add(self.stats, self.stats)
def test_main():
support.run_unittest(
AddCallersTestCase,
StatsTestCase,
)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,4 +1,4 @@
from test.support import verbose, run_unittest, import_module, reap_children
from test.support import verbose, import_module, reap_children
# Skip these tests if termios is not available
import_module('termios')
@ -293,11 +293,8 @@ class SmallPtyTests(unittest.TestCase):
pty._copy(masters[0])
def test_main(verbose=None):
try:
run_unittest(SmallPtyTests, PtyTest)
finally:
reap_children()
def tearDownModule():
reap_children()
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -6,7 +6,7 @@ import xml.sax
from xml.sax.xmlreader import AttributesImpl
from xml.dom import pulldom
from test.support import run_unittest, findfile
from test.support import findfile
tstfile = findfile("test.xml", subdir="xmltestdata")
@ -339,9 +339,5 @@ class SAX2DOMTestCase(unittest.TestCase):
doc.unlink()
def test_main():
run_unittest(PullDOMTestCase, ThoroughTestCase, SAX2DOMTestCase)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -107,8 +107,5 @@ class PwdTest(unittest.TestCase):
self.assertRaises(KeyError, pwd.getpwuid, 2**128)
self.assertRaises(KeyError, pwd.getpwuid, -2**128)
def test_main():
support.run_unittest(PwdTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -2,7 +2,6 @@
Test cases for pyclbr.py
Nick Mathewson
'''
from test.support import run_unittest
import sys
from types import FunctionType, MethodType, BuiltinFunctionType
import pyclbr
@ -173,9 +172,5 @@ class PyclbrTest(TestCase):
self.assertRaises(ImportError, pyclbr.readmodule_ex, 'asyncore.foo')
def test_main():
run_unittest(PyclbrTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -10,7 +10,7 @@ import traceback
from xml.parsers import expat
from xml.parsers.expat import errors
from test.support import sortdict, run_unittest
from test.support import sortdict
class SetAttributeTest(unittest.TestCase):
@ -708,19 +708,5 @@ class ForeignDTDTests(unittest.TestCase):
self.assertEqual(handler_call_args, [("bar", "baz")])
def test_main():
run_unittest(SetAttributeTest,
ParseTest,
NamespaceSeparatorTest,
InterningTest,
BufferTextTest,
HandlerExceptionTest,
PositionTest,
sf1296433Test,
ChardataBufferTest,
MalformedInputTest,
ErrorMessageTest,
ForeignDTDTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -354,10 +354,5 @@ class FailingQueueTest(BlockingTestMixin, unittest.TestCase):
self.failing_queue_test(q)
def test_main():
support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest,
FailingQueueTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,4 +1,3 @@
from test import support
import unittest
import sys, os, io, subprocess
@ -207,9 +206,5 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
p = p.decode('latin-1')
self.assertEqual(cout.splitlines(), p.splitlines())
def test_main():
support.run_unittest(QuopriTestCase)
if __name__ == "__main__":
test_main()
unittest.main()

Some files were not shown because too many files have changed in this diff Show More