]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Give more useful information about a failing PyUnit-style test.
authorFred Drake <fdrake@acm.org>
Mon, 16 Jul 2001 18:51:32 +0000 (18:51 +0000)
committerFred Drake <fdrake@acm.org>
Mon, 16 Jul 2001 18:51:32 +0000 (18:51 +0000)
Lib/test/test_support.py

index 88a3c5e47f6c51f0c2ffaafdfc796c6bdf205a85..3d5c783644f68a8de89e92ed9409be814307d928 100644 (file)
@@ -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])