Skip to content

Commit

Permalink
Revert "Implementation #3 of running other unit tests from scripts_re…
Browse files Browse the repository at this point in the history
…gression_tests"

This reverts commit b33215c.

I think that implementation #2 is probably the best: calling python -m unittest
discover from within a single unit test in scripts_regression_tests
  • Loading branch information
billsacks committed Aug 3, 2016
1 parent b33215c commit 9bea831
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions utils/python/tests/scripts_regression_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()

0 comments on commit 9bea831

Please sign in to comment.