mirror of https://github.com/python/cpython.git
Factor out common boilerplate for test_support
This commit is contained in:
parent
c23fb77477
commit
9dcbbea878
|
@ -192,24 +192,14 @@ def test_backcompatibility(self):
|
|||
|
||||
"""
|
||||
|
||||
#==============================================================================
|
||||
|
||||
def makeAllTests():
|
||||
suite = unittest.TestSuite()
|
||||
for klass in (TestBisect,
|
||||
TestInsort
|
||||
):
|
||||
suite.addTest(unittest.makeSuite(klass))
|
||||
return suite
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
__test__ = {'libreftest' : libreftest}
|
||||
|
||||
def test_main(verbose=None):
|
||||
from test import test_bisect
|
||||
suite = makeAllTests()
|
||||
test_support.run_suite(suite)
|
||||
test_support.run_classtests(TestBisect,
|
||||
TestInsort)
|
||||
test_support.run_doctest(test_bisect, verbose)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -331,9 +331,7 @@ def test_picklevalues(self):
|
|||
self.assertEqual(cPickle.dumps(False, True), "I00\n.")
|
||||
|
||||
def test_main():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(BoolTest))
|
||||
test_support.run_suite(suite)
|
||||
test_support.run_classtests(BoolTest)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
|
||||
warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
|
||||
|
||||
from test.test_support import TESTFN, run_suite
|
||||
from test.test_support import TESTFN, run_classtests
|
||||
|
||||
class TemporaryFileTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -282,14 +282,10 @@ def test_traversal(self):
|
|||
os.rmdir(TESTFN)
|
||||
|
||||
def test_main():
|
||||
suite = unittest.TestSuite()
|
||||
for cls in (TemporaryFileTests,
|
||||
StatAttributeTests,
|
||||
EnvironTests,
|
||||
WalkTests,
|
||||
):
|
||||
suite.addTest(unittest.makeSuite(cls))
|
||||
run_suite(suite)
|
||||
run_classtests(TemporaryFileTests,
|
||||
StatAttributeTests,
|
||||
EnvironTests,
|
||||
WalkTests)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
|
|
@ -233,6 +233,12 @@ def run_unittest(testclass):
|
|||
"""Run tests from a unittest.TestCase-derived class."""
|
||||
run_suite(unittest.makeSuite(testclass), testclass)
|
||||
|
||||
def run_classtests(*classnames):
|
||||
suite = unittest.TestSuite()
|
||||
for cls in classnames:
|
||||
suite.addTest(unittest.makeSuite(cls))
|
||||
run_suite(suite)
|
||||
|
||||
|
||||
#=======================================================================
|
||||
# doctest driver.
|
||||
|
|
Loading…
Reference in New Issue