From 784e1e3b7ecb0987c45668c57b68125c46f46798 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 6 May 2019 12:35:27 -0300 Subject: [PATCH] Add links to pytest.raises `message` workaround Related to #3974 --- doc/en/deprecations.rst | 2 ++ doc/en/getting-started.rst | 2 +- src/_pytest/python_api.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 27af2a49a..a505c0a94 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -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 `. +.. _`raises message deprecated`: + ``"message"`` parameter of ``pytest.raises`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 0ba19cbba..d6c62cbe8 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -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 ` helper to assert that some code raises an exception:: # content of test_sysexit.py import pytest diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 66de85468..84fffd7aa 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -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 ` for a workaround. .. currentmodule:: _pytest._code @@ -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 ` for a workaround. .. note::