MCPcopy Create free account
hub / github.com/pytest-dev/pytest / match

Method match

src/_pytest/_code/code.py:668–680  ·  view source on GitHub ↗

Check whether the regular expression `regexp` matches the string representation of the exception using :func:`python:re.search`. If it matches `True` is returned, otherwise an `AssertionError` is raised.

(self, regexp: Union[str, Pattern[str]])

Source from the content-addressed store, hash-verified

666 return fmt.repr_excinfo(self)
667
668 def match(self, regexp: Union[str, Pattern[str]]) -> "Literal[True]":
669 """Check whether the regular expression `regexp` matches the string
670 representation of the exception using :func:`python:re.search`.
671
672 If it matches `True` is returned, otherwise an `AssertionError` is raised.
673 """
674 __tracebackhide__ = True
675 msg = "Regex pattern {!r} does not match {!r}."
676 if regexp == str(self.value):
677 msg += " Did you mean to `re.escape()` the regex?"
678 assert re.search(regexp, str(self.value)), msg.format(regexp, str(self.value))
679 # Return True to allow for "assert excinfo.match()".
680 return True
681
682
683@attr.s(auto_attribs=True)

Callers 15

re_match_lines_randomMethod · 0.80
re_match_linesMethod · 0.80
no_re_match_lineMethod · 0.80
__exit__Method · 0.80
lexMethod · 0.80
_parse_optionalMethod · 0.80
find_next_versionFunction · 0.80
parse_changelogFunction · 0.80
test_number_reMethod · 0.80
test__get_multicaptureFunction · 0.80

Calls 1

formatMethod · 0.45

Tested by 11

re_match_lines_randomMethod · 0.64
re_match_linesMethod · 0.64
no_re_match_lineMethod · 0.64
test_number_reMethod · 0.64
test__get_multicaptureFunction · 0.64
test_raises_matchMethod · 0.64
test_boolMethod · 0.64
test_tb_entry_strMethod · 0.64
test_match_succeedsFunction · 0.64