MCPcopy Index your code
hub / github.com/RustPython/RustPython / assertWarnsRegex

Method assertWarnsRegex

Lib/unittest/case.py:1421–1438  ·  view source on GitHub ↗

Asserts that the message in a triggered warning matches a regexp. Basic functioning is similar to assertWarns() with the addition that only warnings whose messages also match the regular expression are considered successful matches. Args: expected_warning

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

Source from the content-addressed store, hash-verified

1419 return context.handle('assertRaisesRegex', args, kwargs)
1420
1421 def assertWarnsRegex(self, expected_warning, expected_regex,
1422 *args, **kwargs):
1423 """Asserts that the message in a triggered warning matches a regexp.
1424 Basic functioning is similar to assertWarns() with the addition
1425 that only warnings whose messages also match the regular expression
1426 are considered successful matches.
1427
1428 Args:
1429 expected_warning: Warning class expected to be triggered.
1430 expected_regex: Regex (re.Pattern object or string) expected
1431 to be found in error message.
1432 args: Function to be called and extra positional args.
1433 kwargs: Extra kwargs.
1434 msg: Optional message used in case of failure. Can only be used
1435 when assertWarnsRegex is used as a context manager.
1436 """
1437 context = _AssertWarnsContext(expected_warning, self, expected_regex)
1438 return context.handle('assertWarnsRegex', args, kwargs)
1439
1440 def assertRegex(self, text, expected_regex, msg=None):
1441 """Fail the test unless the text matches the regular expression."""

Callers 15

test_warningsMethod · 0.80
test_decode_warningsMethod · 0.80
genMethod · 0.80
test_asendMethod · 0.80
test_athrowMethod · 0.80
test_acloseMethod · 0.80

Calls 2

_AssertWarnsContextClass · 0.85
handleMethod · 0.45

Tested by 15

test_warningsMethod · 0.64
test_decode_warningsMethod · 0.64
genMethod · 0.64
test_asendMethod · 0.64
test_athrowMethod · 0.64
test_acloseMethod · 0.64