diff options
author | Fred Drake <fdrake@acm.org> | 2001-10-04 19:46:07 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-10-04 19:46:07 (GMT) |
commit | 266410355f7faa7c98b29a16b9f50c56a9224f4b (patch) | |
tree | 1422ac7ca0f3b908930fe7392d7a35f0f48d9219 /Lib | |
parent | 50fda3ba267fe8c063ce83b832f349857ca7fdc3 (diff) | |
download | cpython-266410355f7faa7c98b29a16b9f50c56a9224f4b.zip cpython-266410355f7faa7c98b29a16b9f50c56a9224f4b.tar.gz cpython-266410355f7faa7c98b29a16b9f50c56a9224f4b.tar.bz2 |
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.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_support.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index e1923a6..bbae1be 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -148,7 +148,7 @@ class BasicTestRunner: return result -def run_suite(suite): +def run_suite(suite, testclass=None): """Run tests from a unittest.TestSuite-derived class.""" if verbose: runner = unittest.TextTestRunner(sys.stdout, verbosity=2) @@ -162,14 +162,18 @@ def run_suite(suite): elif len(result.failures) == 1 and not result.errors: err = result.failures[0][1] else: - raise TestFailed("errors occurred in %s.%s" - % (testclass.__module__, testclass.__name__)) + if testclass is None: + 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) def run_unittest(testclass): """Run tests from a unittest.TestCase-derived class.""" - run_suite(unittest.makeSuite(testclass)) + run_suite(unittest.makeSuite(testclass), testclass) #======================================================================= |