Update various test modules to use unittest.main() for test discovery

instead of manually listing tests for test.support.run_unittest().
This commit is contained in:
Brett Cannon 2013-06-12 21:25:59 -04:00
parent e382b5868a
commit 3e9a9ae09d
18 changed files with 24 additions and 108 deletions

View File

@ -951,9 +951,6 @@ class ASTValidatorTests(unittest.TestCase):
compile(mod, fn, "exec")
def test_main():
support.run_unittest(AST_Tests, ASTHelpers_Test, ASTValidatorTests)
def main():
if __name__ != '__main__':
return
@ -966,7 +963,7 @@ def main():
print("]")
print("main()")
raise SystemExit
test_main()
unittest.main()
#### EVERYTHING BELOW IS GENERATED #####
exec_results = [

View File

@ -283,9 +283,5 @@ class TestFifo(unittest.TestCase):
self.assertEqual(f.pop(), (0, None))
def test_main(verbose=None):
support.run_unittest(TestAsynchat, TestAsynchat_WithPoll,
TestHelperFunctions, TestFifo)
if __name__ == "__main__":
test_main(verbose=True)
unittest.main()

View File

@ -4283,9 +4283,5 @@ class TestBufferProtocol(unittest.TestCase):
self.assertRaises(BufferError, memoryview, x)
def test_main():
support.run_unittest(TestBufferProtocol)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -875,8 +875,6 @@ class CodecCallbackTest(unittest.TestCase):
with self.assertRaises(TypeError):
data.decode(encoding, "test.replacing")
def test_main():
test.support.run_unittest(CodecCallbackTest)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -617,9 +617,5 @@ class TestIgnored(unittest.TestCase):
'Hello'[50]
# This is needed to make the test actually run under regrtest.py!
def test_main():
support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -588,8 +588,5 @@ sys.exit(exitcode)
self.check_register(chain=True)
def test_main():
support.run_unittest(FaultHandlerTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -835,22 +835,6 @@ class Test_hook_encoded(unittest.TestCase):
self.assertIs(kwargs.pop('encoding'), encoding)
self.assertFalse(kwargs)
def test_main():
run_unittest(
BufferSizesTests,
FileInputTests,
Test_fileinput_input,
Test_fileinput_close,
Test_fileinput_nextfile,
Test_fileinput_filename,
Test_fileinput_lineno,
Test_fileinput_filelineno,
Test_fileinput_fileno,
Test_fileinput_isfirstline,
Test_fileinput_isstdin,
Test_hook_compressed,
Test_hook_encoded,
)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -72,8 +72,6 @@ class FrozenTests(unittest.TestCase):
del sys.modules['__phello__']
del sys.modules['__phello__.spam']
def test_main():
run_unittest(FrozenTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1,6 +1,10 @@
import unittest
from test import support
from _testcapi import getargs_keywords, getargs_keyword_only
try:
from _testcapi import getargs_L, getargs_K
except ImportError:
getargs_L = None # PY_LONG_LONG not available
# > How about the following counterproposal. This also changes some of
# > the other format codes to be a little more regular.
@ -182,6 +186,7 @@ class Signed_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
@unittest.skipIf(getargs_L is None, 'PY_LONG_LONG is not available')
class LongLong_TestCase(unittest.TestCase):
def test_L(self):
from _testcapi import getargs_L
@ -534,24 +539,5 @@ class Unicode_TestCase(unittest.TestCase):
self.assertIsNone(getargs_Z_hash(None))
def test_main():
tests = [
Signed_TestCase,
Unsigned_TestCase,
Boolean_TestCase,
Tuple_TestCase,
Keywords_TestCase,
KeywordOnly_TestCase,
Bytes_TestCase,
Unicode_TestCase,
]
try:
from _testcapi import getargs_L, getargs_K
except ImportError:
pass # PY_LONG_LONG not available
else:
tests.append(LongLong_TestCase)
support.run_unittest(*tests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -494,8 +494,6 @@ class HashLibTestCase(unittest.TestCase):
self.assertEqual(expected_hash, hasher.hexdigest())
def test_main():
support.run_unittest(HashLibTestCase)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -86,8 +86,6 @@ class IoctlTests(unittest.TestCase):
os.close(mfd)
os.close(sfd)
def test_main():
run_unittest(IoctlTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -575,12 +575,5 @@ s = "non-ASCII: h\xe9"
self.assertEqual(result['s'], "non-ASCII: h\xe9")
def test_main():
run_unittest(
ExecutionLayerTestCase,
RunModuleTestCase,
RunPathTestCase
)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -197,8 +197,5 @@ class TestCase(unittest.TestCase):
self.assertEqual(l, [])
def test_main():
support.run_unittest(TestCase)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -1719,9 +1719,5 @@ class TermsizeTests(unittest.TestCase):
self.assertEqual(expected, actual)
def test_main():
support.run_unittest(TestShutil, TestMove, TestCopyFile,
TermsizeTests, TestWhich)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -401,8 +401,6 @@ class ImportSideEffectTests(unittest.TestCase):
else:
self.fail("sitecustomize not imported automatically")
def test_main():
run_unittest(HelperFunctionsTests, ImportSideEffectTests)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -176,8 +176,6 @@ class StrftimeTest(unittest.TestCase):
(e[0], e[2]))
print(" Expected %s, but got %s" % (e[1], result))
def test_main():
support.run_unittest(StrftimeTest)
if __name__ == '__main__':
test_main()
unittest.main()

View File

@ -54,8 +54,5 @@ class TestUntestedModules(unittest.TestCase):
print("skipping tty")
def test_main():
support.run_unittest(TestUntestedModules)
if __name__ == "__main__":
test_main()
unittest.main()

View File

@ -338,13 +338,6 @@ class TimeoutTest(unittest.TestCase):
self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60)
def test_main():
support.requires("network")
support.run_unittest(AuthTests,
OtherNetworkTests,
CloseSocketTest,
TimeoutTest,
)
if __name__ == "__main__":
test_main()
support.requires("network")
unittest.main()