Merge pull request #5223 from 5uper5hoot/patch-1

Clarify docs for pytest.raises `match`.
This commit is contained in:
Bruno Oliveira 2019-05-06 21:57:47 -03:00 committed by GitHub
commit 6d259c400e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -558,7 +558,13 @@ def raises(expected_exception, *args, **kwargs):
Assert that a code block/function call raises ``expected_exception``
or raise a failure exception otherwise.
:kwparam match: if specified, asserts that the exception matches a text or regex
: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
string that may contain `special characters`__, the pattern can
first be escaped with ``re.escape``.
__ https://docs.python.org/3/library/re.html#regular-expression-syntax
:kwparam message: **(deprecated since 4.1)** if specified, provides a custom failure message
if the exception is not raised. See :ref:`the deprecation docs <raises message deprecated>` for a workaround.