Skip to content

Commit 6663cb0

Browse files
authored
Fix documentation of pytest.raises(match=...) (#5288)
Fix documentation of pytest.raises(match=...)
2 parents ee52a8a + b27e40c commit 6663cb0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/_pytest/_code/code.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,11 @@ def __unicode__(self):
564564

565565
def match(self, regexp):
566566
"""
567-
Match the regular expression 'regexp' on the string representation of
568-
the exception. If it matches then True is returned (so that it is
569-
possible to write 'assert excinfo.match()'). If it doesn't match an
570-
AssertionError is raised.
567+
Check whether the regular expression 'regexp' is found in the string
568+
representation of the exception using ``re.search``. If it matches
569+
then True is returned (so that it is possible to write
570+
``assert excinfo.match()``). If it doesn't match an AssertionError is
571+
raised.
571572
"""
572573
__tracebackhide__ = True
573574
if not re.search(regexp, str(self.value)):

src/_pytest/python_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def raises(expected_exception, *args, **kwargs):
559559
560560
:kwparam match: if specified, a string containing a regular expression,
561561
or a regular expression object, that is tested against the string
562-
representation of the exception using ``re.match``. To match a literal
562+
representation of the exception using ``re.search``. To match a literal
563563
string that may contain `special characters`__, the pattern can
564564
first be escaped with ``re.escape``.
565565

0 commit comments

Comments
 (0)