mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
e382b5868a
commit
3e9a9ae09d
18 changed files with 24 additions and 108 deletions
|
@ -951,9 +951,6 @@ class ASTValidatorTests(unittest.TestCase):
|
||||||
compile(mod, fn, "exec")
|
compile(mod, fn, "exec")
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(AST_Tests, ASTHelpers_Test, ASTValidatorTests)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if __name__ != '__main__':
|
if __name__ != '__main__':
|
||||||
return
|
return
|
||||||
|
@ -966,7 +963,7 @@ def main():
|
||||||
print("]")
|
print("]")
|
||||||
print("main()")
|
print("main()")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
||||||
#### EVERYTHING BELOW IS GENERATED #####
|
#### EVERYTHING BELOW IS GENERATED #####
|
||||||
exec_results = [
|
exec_results = [
|
||||||
|
|
|
@ -283,9 +283,5 @@ class TestFifo(unittest.TestCase):
|
||||||
self.assertEqual(f.pop(), (0, None))
|
self.assertEqual(f.pop(), (0, None))
|
||||||
|
|
||||||
|
|
||||||
def test_main(verbose=None):
|
|
||||||
support.run_unittest(TestAsynchat, TestAsynchat_WithPoll,
|
|
||||||
TestHelperFunctions, TestFifo)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main(verbose=True)
|
unittest.main()
|
||||||
|
|
|
@ -4283,9 +4283,5 @@ class TestBufferProtocol(unittest.TestCase):
|
||||||
self.assertRaises(BufferError, memoryview, x)
|
self.assertRaises(BufferError, memoryview, x)
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(TestBufferProtocol)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -875,8 +875,6 @@ class CodecCallbackTest(unittest.TestCase):
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
data.decode(encoding, "test.replacing")
|
data.decode(encoding, "test.replacing")
|
||||||
|
|
||||||
def test_main():
|
|
||||||
test.support.run_unittest(CodecCallbackTest)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -617,9 +617,5 @@ class TestIgnored(unittest.TestCase):
|
||||||
'Hello'[50]
|
'Hello'[50]
|
||||||
|
|
||||||
|
|
||||||
# This is needed to make the test actually run under regrtest.py!
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(__name__)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -588,8 +588,5 @@ sys.exit(exitcode)
|
||||||
self.check_register(chain=True)
|
self.check_register(chain=True)
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(FaultHandlerTests)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -835,22 +835,6 @@ class Test_hook_encoded(unittest.TestCase):
|
||||||
self.assertIs(kwargs.pop('encoding'), encoding)
|
self.assertIs(kwargs.pop('encoding'), encoding)
|
||||||
self.assertFalse(kwargs)
|
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__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -72,8 +72,6 @@ class FrozenTests(unittest.TestCase):
|
||||||
del sys.modules['__phello__']
|
del sys.modules['__phello__']
|
||||||
del sys.modules['__phello__.spam']
|
del sys.modules['__phello__.spam']
|
||||||
|
|
||||||
def test_main():
|
|
||||||
run_unittest(FrozenTests)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import unittest
|
import unittest
|
||||||
from test import support
|
from test import support
|
||||||
from _testcapi import getargs_keywords, getargs_keyword_only
|
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
|
# > How about the following counterproposal. This also changes some of
|
||||||
# > the other format codes to be a little more regular.
|
# > 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)
|
self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(getargs_L is None, 'PY_LONG_LONG is not available')
|
||||||
class LongLong_TestCase(unittest.TestCase):
|
class LongLong_TestCase(unittest.TestCase):
|
||||||
def test_L(self):
|
def test_L(self):
|
||||||
from _testcapi import getargs_L
|
from _testcapi import getargs_L
|
||||||
|
@ -534,24 +539,5 @@ class Unicode_TestCase(unittest.TestCase):
|
||||||
self.assertIsNone(getargs_Z_hash(None))
|
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__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -494,8 +494,6 @@ class HashLibTestCase(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(expected_hash, hasher.hexdigest())
|
self.assertEqual(expected_hash, hasher.hexdigest())
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(HashLibTestCase)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -86,8 +86,6 @@ class IoctlTests(unittest.TestCase):
|
||||||
os.close(mfd)
|
os.close(mfd)
|
||||||
os.close(sfd)
|
os.close(sfd)
|
||||||
|
|
||||||
def test_main():
|
|
||||||
run_unittest(IoctlTests)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -575,12 +575,5 @@ s = "non-ASCII: h\xe9"
|
||||||
self.assertEqual(result['s'], "non-ASCII: h\xe9")
|
self.assertEqual(result['s'], "non-ASCII: h\xe9")
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
run_unittest(
|
|
||||||
ExecutionLayerTestCase,
|
|
||||||
RunModuleTestCase,
|
|
||||||
RunPathTestCase
|
|
||||||
)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -197,8 +197,5 @@ class TestCase(unittest.TestCase):
|
||||||
self.assertEqual(l, [])
|
self.assertEqual(l, [])
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(TestCase)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -1719,9 +1719,5 @@ class TermsizeTests(unittest.TestCase):
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(TestShutil, TestMove, TestCopyFile,
|
|
||||||
TermsizeTests, TestWhich)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -401,8 +401,6 @@ class ImportSideEffectTests(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
self.fail("sitecustomize not imported automatically")
|
self.fail("sitecustomize not imported automatically")
|
||||||
|
|
||||||
def test_main():
|
|
||||||
run_unittest(HelperFunctionsTests, ImportSideEffectTests)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -176,8 +176,6 @@ class StrftimeTest(unittest.TestCase):
|
||||||
(e[0], e[2]))
|
(e[0], e[2]))
|
||||||
print(" Expected %s, but got %s" % (e[1], result))
|
print(" Expected %s, but got %s" % (e[1], result))
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(StrftimeTest)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -54,8 +54,5 @@ class TestUntestedModules(unittest.TestCase):
|
||||||
print("skipping tty")
|
print("skipping tty")
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
|
||||||
support.run_unittest(TestUntestedModules)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
unittest.main()
|
||||||
|
|
|
@ -338,13 +338,6 @@ class TimeoutTest(unittest.TestCase):
|
||||||
self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60)
|
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__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
support.requires("network")
|
||||||
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue