TestCase.assertRaisesRegex(expected_exception, expected_regex, *args, **kwargs)[source]

Asserts that the message in a raised exception matches a regex.


expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected

to be found in error message.

args: Function to be called and extra positional args. kwargs: Extra kwargs. msg: Optional message used in case of failure. Can only be used

when assertRaisesRegex is used as a context manager.