From 9bea831f532e9063caeaba5f743160b24c2675d6 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Wed, 3 Aug 2016 05:52:31 -0600 Subject: [PATCH] Revert "Implementation #3 of running other unit tests from scripts_regression_tests" This reverts commit b33215cfe2c41439c50c91455d32efc898d570cd. I think that implementation #2 is probably the best: calling python -m unittest discover from within a single unit test in scripts_regression_tests --- .../python/tests/scripts_regression_tests.py | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/utils/python/tests/scripts_regression_tests.py b/utils/python/tests/scripts_regression_tests.py index 2234dea2e95..36dc536cbe4 100755 --- a/utils/python/tests/scripts_regression_tests.py +++ b/utils/python/tests/scripts_regression_tests.py @@ -39,6 +39,23 @@ def do_unit_tests(self, script,from_dir=SCRIPT_DIR): stat, output, _ = run_cmd("./%s --test 2>&1" % script, from_dir=from_dir) self.assertEqual(stat, 0, msg=output) + def test_unittests(self): + # Finds all files contained in LIB_DIR or its subdirectories that match + # the pattern 'test*.py', and runs the unit tests found there (i.e., + # tests defined using python's unittest module). + # + # This is analogous to running: + # python -m unittest discover + # + # It seems kind of funny to run a bunch of other unit test suites from + # within this single unit test, but doing it this way makes it + # consistent with how we run other tests in this module. + + cmd = 'python -m unittest discover' + stat, output, _ = run_cmd("%s 2>&1"%cmd, from_dir = LIB_DIR) + + self.assertEqual(stat, 0, msg=output) + def test_cime_bisect_unit_test(self): self.do_unit_tests("cime_bisect",from_dir=TOOLS_DIR) @@ -1630,25 +1647,7 @@ def _main_func(): CIME.utils.handle_standard_logging_options(args) - # Finds all files contained in LIB_DIR or its subdirectories that match the - # pattern 'test*.py', and runs the unit tests found there (i.e., tests - # defined using python's unittest module). - # - # This is analogous to running: - # python -m unittest discover - testsuite_from_discovery = \ - unittest.defaultTestLoader.discover(start_dir=LIB_DIR) - - # Add tests defined in this module - testsuite_from_this_module = \ - unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]) - - # Run all tests found here and elsewhere - suitelist = [testsuite_from_discovery, testsuite_from_this_module] - fullsuite = unittest.TestSuite(suitelist) - unittest.installHandler() - unittest.TextTestRunner(verbosity=2).run(fullsuite) - + unittest.main(verbosity=2, catchbreak=True) if (__name__ == "__main__"): _main_func()