summaryrefslogtreecommitdiffstats
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-10 09:10:40 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-10 09:10:40 (GMT)
commit2b6a97e69cd33ac7389b0e42c243b47e3d23f2fb (patch)
tree71b148d25a6ea785d2a441e43f1049dd1cdb2be4 /Lib/unittest.py
parenta0982944464b94c2965e4776f376b66903f82764 (diff)
downloadcpython-2b6a97e69cd33ac7389b0e42c243b47e3d23f2fb.zip
cpython-2b6a97e69cd33ac7389b0e42c243b47e3d23f2fb.tar.gz
cpython-2b6a97e69cd33ac7389b0e42c243b47e3d23f2fb.tar.bz2
Add the function/method name to assertRaises.
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 16f062b..931d2f6 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 '=='