summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-07-16 18:51:32 (GMT)
committerFred Drake <fdrake@acm.org>2001-07-16 18:51:32 (GMT)
commit14f6c18b6250b66777b6e46003c5f37ef6327890 (patch)
treefc75c343a6c2fc0d5aec3188756f26c74b8817a5 /Lib/test/test_support.py
parent50bc19fce54a22f06eb777711b75a1bfd1c0b86b (diff)
downloadcpython-14f6c18b6250b66777b6e46003c5f37ef6327890.zip
cpython-14f6c18b6250b66777b6e46003c5f37ef6327890.tar.gz
cpython-14f6c18b6250b66777b6e46003c5f37ef6327890.tar.bz2
Give more useful information about a failing PyUnit-style test.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 88a3c5e..3d5c783 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -135,5 +135,14 @@ def run_unittest(testclass):
suite = unittest.makeSuite(testclass)
result = runner.run(suite)
if not result.wasSuccessful():
- raise TestFailed("errors occurred in %s.%s"
- % (testclass.__module__, testclass.__name__))
+ if len(result.errors) == 1 and not result.failures:
+ err = result.errors[0][1]
+ 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 err[0] is AssertionError:
+ raise TestFailed(str(err[1]))
+ else:
+ raise TestFailed("%s: %s" % err[:2])