From 2b6a97e69cd33ac7389b0e42c243b47e3d23f2fb Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 10 Jul 2007 09:10:40 +0000 Subject: [PATCH] Add the function/method name to assertRaises. --- Lib/unittest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/unittest.py b/Lib/unittest.py index 16f062b3ab5..931d2f6f72a 100644 --- a/Lib/unittest.py +++ b/Lib/unittest.py @@ -311,9 +311,10 @@ class TestCase: except excClass: return else: - if hasattr(excClass,'__name__'): excName = excClass.__name__ - else: excName = str(excClass) - raise self.failureException, "%s not raised" % excName + excName = str(getattr(excClass, '__name__', excClass)) + objName = str(getattr(callableObj, '__name__', callableObj)) + raise self.failureException, "%s not raised by %s" % (excName, + objName) def failUnlessEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '=='