Created
October 10, 2011 14:53
-
-
Save felipe-prenholato/1275520 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExTestCase(TestCase): | |
def assertRaisesMessage(self, expected_exception, expected_message, | |
callable_obj=None, *args, **kwargs): | |
""" | |
Asserts that the message in a raised exception matches the passed | |
value. | |
Args: | |
expected_exception: Exception class expected to be raised. | |
expected_message: expected error message string value. | |
callable_obj: Function to be called. | |
args: Extra args. | |
kwargs: Extra kwargs. | |
""" | |
try: | |
callable_obj(*args,**kwargs) | |
except Exception, err: | |
self.assertTrue(isinstance(err,expected_exception),u"Raise something unexpected!") | |
self.assertEquals(err.message,expected_message) | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment