Skip to content
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

Add an example on how to update config.warn calls #4029

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions doc/en/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,24 @@ Below is a complete list of all pytest features which are considered deprecated.
Those methods were part of the internal pytest warnings system, but since ``3.8`` pytest is using the builtin warning
system for its own warnings, so those two functions are now deprecated.

``Config.warn`` should be replaced by calls to the standard ``warnings.warn``.
``Config.warn`` should be replaced by calls to the standard ``warnings.warn``, example:

.. code-block:: python

config.warn("C1", "some warning")

Becomes:

.. code-block:: python

warnings.warn(pytest.PytestWarning("some warning"))

``Node.warn`` now supports two signatures:

* ``node.warn(PytestWarning("some message"))``: is now the recommended way to call this function.
* ``node.warn(PytestWarning("some message"))``: is now the **recommended** way to call this function.
The warning instance must be a PytestWarning or subclass.

* ``node.warn("CI", "some message")``: this code/message form is now deprecated and should be converted to the warning instance form above.
* ``node.warn("CI", "some message")``: this code/message form is now **deprecated** and should be converted to the warning instance form above.


``pytest_namespace``
Expand Down