Skip to content

Add links to pytest.raises message workaround #5218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/en/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Below is a complete list of all pytest features which are considered deprecated.
:class:`_pytest.warning_types.PytestWarning` or subclasses, which can be filtered using
:ref:`standard warning filters <warnings>`.

.. _`raises message deprecated`:

``"message"`` parameter of ``pytest.raises``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion doc/en/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Run multiple tests
Assert that a certain exception is raised
--------------------------------------------------------------

Use the ``raises`` helper to assert that some code raises an exception::
Use the :ref:`raises <assertraises>` helper to assert that some code raises an exception::

# content of test_sysexit.py
import pytest
Expand Down
3 changes: 2 additions & 1 deletion src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def raises(expected_exception, *args, **kwargs):
:kwparam match: if specified, asserts that the exception matches a text or regex

:kwparam message: **(deprecated since 4.1)** if specified, provides a custom failure message
if the exception is not raised
if the exception is not raised. See :ref:`the deprecation docs <raises message deprecated>` for a workaround.

.. currentmodule:: _pytest._code

Expand Down Expand Up @@ -597,6 +597,7 @@ def raises(expected_exception, *args, **kwargs):
``message`` to specify a custom failure message that will be displayed
in case the ``pytest.raises`` check fails. This has been deprecated as it
is considered error prone as users often mean to use ``match`` instead.
See :ref:`the deprecation docs <raises message deprecated>` for a workaround.

.. note::

Expand Down