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]])
| 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) |