Commit 26641035 authored by Fred Drake's avatar Fred Drake

run_suite(): If testclass is not available, provide an even more general

               error message.
run_unittest():  Provide the testclass to run_suite() so it can construct
                 the error message.
This closes SF bug #467763.
parent 50fda3ba
...@@ -148,7 +148,7 @@ class BasicTestRunner: ...@@ -148,7 +148,7 @@ class BasicTestRunner:
return result return result
def run_suite(suite): def run_suite(suite, testclass=None):
"""Run tests from a unittest.TestSuite-derived class.""" """Run tests from a unittest.TestSuite-derived class."""
if verbose: if verbose:
runner = unittest.TextTestRunner(sys.stdout, verbosity=2) runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
...@@ -162,14 +162,18 @@ def run_suite(suite): ...@@ -162,14 +162,18 @@ def run_suite(suite):
elif len(result.failures) == 1 and not result.errors: elif len(result.failures) == 1 and not result.errors:
err = result.failures[0][1] err = result.failures[0][1]
else: else:
raise TestFailed("errors occurred in %s.%s" if testclass is None:
% (testclass.__module__, testclass.__name__)) msg = "errors occurred; run in verbose mode for details"
else:
msg = "errors occurred in %s.%s" \
% (testclass.__module__, testclass.__name__)
raise TestFailed(msg)
raise TestFailed(err) raise TestFailed(err)
def run_unittest(testclass): def run_unittest(testclass):
"""Run tests from a unittest.TestCase-derived class.""" """Run tests from a unittest.TestCase-derived class."""
run_suite(unittest.makeSuite(testclass)) run_suite(unittest.makeSuite(testclass), testclass)
#======================================================================= #=======================================================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment