Skip to content

Commit 5d8467b

Browse files
Merge pull request #4023 from nicoddemus/deprecated-3.9
Add 3.9 deprecated features to deprecations.rst
2 parents e03a19f + 0d04aa7 commit 5d8467b

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

doc/en/deprecations.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,67 @@ Below is a complete list of all pytest features which are considered deprecated.
1414
:class:`_pytest.warning_types.PytestWarning` or subclasses, which can be filtered using
1515
:ref:`standard warning filters <warnings>`.
1616

17+
Internal classes accessed through ``Node``
18+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
20+
.. deprecated:: 3.9
21+
22+
Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances now issue
23+
this warning::
24+
25+
usage of Function.Module is deprecated, please use pytest.Module instead
26+
27+
Users should just ``import pytest`` and access those objects using the ``pytest`` module.
28+
29+
This has been documented as deprecated for years, but only now we are actually emitting deprecation warnings.
30+
31+
``cached_setup``
32+
~~~~~~~~~~~~~~~~
33+
34+
.. deprecated:: 3.9
35+
36+
``request.cached_setup`` was the precursor of the setup/teardown mechanism available to fixtures.
37+
38+
Example:
39+
40+
.. code-block:: python
41+
42+
@pytest.fixture
43+
def db_session():
44+
return request.cached_setup(
45+
setup=Session.create, teardown=lambda session: session.close(), scope="module"
46+
)
47+
48+
This should be updated to make use of standard fixture mechanisms:
49+
50+
.. code-block:: python
51+
52+
@pytest.fixture(scope="module")
53+
def db_session():
54+
session = Session.create()
55+
yield session
56+
session.close()
57+
58+
59+
You can consult `funcarg comparision section in the docs <https://docs.pytest.org/en/latest/funcarg_compare.html>`_ for
60+
more information.
61+
62+
This has been documented as deprecated for years, but only now we are actually emitting deprecation warnings.
63+
64+
65+
Using ``Class`` in custom Collectors
66+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67+
68+
.. deprecated:: 3.9
69+
70+
Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector``
71+
subclasses has been deprecated. Users instead should use ``pytest_collect_make_item`` to customize node types during
72+
collection.
73+
74+
This issue should affect only advanced plugins who create new collection types, so if you see this warning
75+
message please contact the authors so they can change the code.
76+
77+
1778
``Config.warn`` and ``Node.warn``
1879
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1980

0 commit comments

Comments
 (0)