Skip to content
Merged
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
148 changes: 74 additions & 74 deletions doc/en/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,6 @@ Becomes:
exec("assert(1, 2)") # exec is used to avoid a top-level warning


Internal classes accessed through ``Node``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 3.9

Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances now issue
this warning::

usage of Function.Module is deprecated, please use pytest.Module instead

Users should just ``import pytest`` and access those objects using the ``pytest`` module.

This has been documented as deprecated for years, but only now we are actually emitting deprecation warnings.

``cached_setup``
~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -138,40 +125,6 @@ Becomes:
* ``node.warn("CI", "some message")``: this code/message form is now **deprecated** and should be converted to the warning instance form above.


``pytest_namespace``
~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 3.7

This hook is deprecated because it greatly complicates the pytest internals regarding configuration and initialization, making some
bug fixes and refactorings impossible.

Example of usage:

.. code-block:: python

class MySymbol:
...


def pytest_namespace():
return {"my_symbol": MySymbol()}


Plugin authors relying on this hook should instead require that users now import the plugin modules directly (with an appropriate public API).

As a stopgap measure, plugin authors may still inject their names into pytest's namespace, usually during ``pytest_configure``:

.. code-block:: python

import pytest


def pytest_configure():
pytest.my_symbol = MySymbol()



Calling fixtures directly
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -314,12 +267,54 @@ By passing a string, users expect that pytest will interpret that command-line u
on (for example ``bash`` or ``Powershell``), but this is very hard/impossible to do in a portable way.


``pytest_funcarg__`` prefix
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 3.0

In very early pytest versions fixtures could be defined using the ``pytest_funcarg__`` prefix:

.. code-block:: python

def pytest_funcarg__data():
return SomeData()

Switch over to the ``@pytest.fixture`` decorator:

.. code-block:: python

@pytest.fixture
def data():
return SomeData()

[pytest] section in setup.cfg files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 3.0

``[pytest]`` sections in ``setup.cfg`` files should now be named ``[tool:pytest]``
to avoid conflicts with other distutils commands.

Result log (``--result-log``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 3.0

The ``--resultlog`` command line option has been deprecated: it is little used
and there are more modern and better alternatives, for example `pytest-tap <https://tappy.readthedocs.io/en/latest/>`_.

Removed Features
----------------

As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
an appropriate period of deprecation has passed.

``yield`` tests
~~~~~~~~~~~~~~~

.. deprecated:: 3.0
*Removed in version 4.0.*

pytest supports ``yield``-style tests, where a test function actually ``yield`` functions and values
pytest supported ``yield``-style tests, where a test function actually ``yield`` functions and values
that are then turned into proper test methods. Example:

.. code-block:: python
Expand All @@ -342,48 +337,53 @@ This form of test function doesn't support fixtures properly, and users should s
def test_squared(x, y):
assert x ** x == y

Internal classes accessed through ``Node``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``pytest_funcarg__`` prefix
~~~~~~~~~~~~~~~~~~~~~~~~~~~
*Removed in version 4.0.*

.. deprecated:: 3.0
Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances now issue
this warning::

In very early pytest versions fixtures could be defined using the ``pytest_funcarg__`` prefix:
usage of Function.Module is deprecated, please use pytest.Module instead

.. code-block:: python
Users should just ``import pytest`` and access those objects using the ``pytest`` module.

def pytest_funcarg__data():
return SomeData()
This has been documented as deprecated for years, but only now we are actually emitting deprecation warnings.

Switch over to the ``@pytest.fixture`` decorator:
``pytest_namespace``
~~~~~~~~~~~~~~~~~~~~

*Removed in version 4.0.*

This hook is deprecated because it greatly complicates the pytest internals regarding configuration and initialization, making some
bug fixes and refactorings impossible.

Example of usage:

.. code-block:: python

@pytest.fixture
def data():
return SomeData()
class MySymbol:
...

[pytest] section in setup.cfg files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 3.0
def pytest_namespace():
return {"my_symbol": MySymbol()}

``[pytest]`` sections in ``setup.cfg`` files should now be named ``[tool:pytest]``
to avoid conflicts with other distutils commands.

Result log (``--result-log``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Plugin authors relying on this hook should instead require that users now import the plugin modules directly (with an appropriate public API).

.. deprecated:: 3.0
As a stopgap measure, plugin authors may still inject their names into pytest's namespace, usually during ``pytest_configure``:

The ``--resultlog`` command line option has been deprecated: it is little used
and there are more modern and better alternatives, for example `pytest-tap <https://tappy.readthedocs.io/en/latest/>`_.
.. code-block:: python

import pytest


def pytest_configure():
pytest.my_symbol = MySymbol()

Removed Features
----------------

As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
an appropriate period of deprecation has passed.


Reinterpretation mode (``--assert=reinterp``)
Expand Down