Skip to content

Commit

Permalink
Fix documentation of pytest.raises(match=...) (#5288)
Browse files Browse the repository at this point in the history
Fix documentation of pytest.raises(match=...)
  • Loading branch information
nicoddemus authored May 19, 2019
2 parents ee52a8a + b27e40c commit 6663cb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,11 @@ def __unicode__(self):

def match(self, regexp):
"""
Match the regular expression 'regexp' on the string representation of
the exception. If it matches then True is returned (so that it is
possible to write 'assert excinfo.match()'). If it doesn't match an
AssertionError is raised.
Check whether the regular expression 'regexp' is found in the string
representation of the exception using ``re.search``. If it matches
then True is returned (so that it is possible to write
``assert excinfo.match()``). If it doesn't match an AssertionError is
raised.
"""
__tracebackhide__ = True
if not re.search(regexp, str(self.value)):
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def raises(expected_exception, *args, **kwargs):
:kwparam match: if specified, a string containing a regular expression,
or a regular expression object, that is tested against the string
representation of the exception using ``re.match``. To match a literal
representation of the exception using ``re.search``. To match a literal
string that may contain `special characters`__, the pattern can
first be escaped with ``re.escape``.
Expand Down

0 comments on commit 6663cb0

Please sign in to comment.