MCPcopy Index your code
hub / github.com/python/cpython / assertRaisesRegex

Method assertRaisesRegex

Lib/unittest/case.py:1400–1414  ·  view source on GitHub ↗

Asserts that the message in a raised exception matches a regex. Args: 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

(self, expected_exception, expected_regex,
                          *args, **kwargs)

Source from the content-addressed store, hash-verified

1398 self.fail(self._formatMessage(msg, standardMsg))
1399
1400 def assertRaisesRegex(self, expected_exception, expected_regex,
1401 *args, **kwargs):
1402 """Asserts that the message in a raised exception matches a regex.
1403
1404 Args:
1405 expected_exception: Exception class expected to be raised.
1406 expected_regex: Regex (re.Pattern object or string) expected
1407 to be found in error message.
1408 args: Function to be called and extra positional args.
1409 kwargs: Extra kwargs.
1410 msg: Optional message used in case of failure. Can only be used
1411 when assertRaisesRegex is used as a context manager.
1412 """
1413 context = _AssertRaisesContext(expected_exception, self, expected_regex)
1414 return context.handle('assertRaisesRegex', args, kwargs)
1415
1416 def assertWarnsRegex(self, expected_warning, expected_regex,
1417 *args, **kwargs):

Calls 2

handleMethod · 0.45