tests: improve assertNotRaises reporting

Include whole exception value, not only its type.
This commit is contained in:
Marek Marczykowski-Górecki 2016-02-10 17:06:45 +01:00 committed by Wojtek Porczyk
parent f52a0f2d41
commit 2966456387

View File

@ -147,14 +147,9 @@ class _AssertNotRaisesContext(object):
if exc_type is None:
return True
try:
exc_name = self.expected.__name__
except AttributeError:
exc_name = str(self.expected)
if issubclass(exc_type, self.expected):
raise self.failureException(
"{0} raised".format(exc_name))
"{!r} raised".format(exc_value))
else:
# pass through
return False