You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Improve reference and path/fspath docs
Closes#9283
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fixups
* Add explanation
* Update wording after #9363
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
``py.path.local`` arguments for hooks have been deprecated. See :ref:`the deprecation note <legacy-path-hooks-deprecated>` for full details.
2
2
3
3
``py.path.local`` arguments to Node constructors have been deprecated. See :ref:`the deprecation note <node-ctor-fspath-deprecation>` for full details.
4
+
5
+
.. note::
6
+
The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
7
+
new attribute being ``path``) is **the opposite** of the situation for hooks
8
+
(the old argument being ``path``).
9
+
10
+
This is an unfortunate artifact due to historical reasons, which should be
11
+
resolved in future versions as we slowly get rid of the :pypi:`py`
12
+
dependency (see :issue:`9283` for a longer discussion).
Implement ``Node.path`` as a ``pathlib.Path``. Both the old ``fspath`` and this new attribute gets set no matter whether ``path`` or ``fspath`` (deprecated) is passed to the constructor. It is a replacement for the ``fspath`` attribute (which represents the same path as ``py.path.local``). While ``fspath`` is not deprecated yet
2
+
due to the ongoing migration of methods like :meth:`~_pytest.Item.reportinfo`, we expect to deprecate it in a future release.
3
+
4
+
.. note::
5
+
The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
6
+
new attribute being ``path``) is **the opposite** of the situation for hooks
7
+
(the old argument being ``path``).
8
+
9
+
This is an unfortunate artifact due to historical reasons, which should be
10
+
resolved in future versions as we slowly get rid of the :pypi:`py`
11
+
dependency (see :issue:`9283` for a longer discussion).
Copy file name to clipboardExpand all lines: doc/en/deprecations.rst
+27-2
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,24 @@ Plugins which construct nodes should pass the ``path`` argument, of type
53
53
:class:`pathlib.Path`, instead of the ``fspath`` argument.
54
54
55
55
Plugins which implement custom items and collectors are encouraged to replace
56
-
``py.path.local`` ``fspath`` parameters with ``pathlib.Path`` parameters, and
57
-
drop any other usage of the ``py`` library if possible.
56
+
``fspath`` parameters (``py.path.local``) with ``path`` parameters
57
+
(``pathlib.Path``), and drop any other usage of the ``py`` library if possible.
58
58
59
+
.. note::
60
+
The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
61
+
new attribute being ``path``) is **the opposite** of the situation for
62
+
hooks, :ref:`outlined below <legacy-path-hooks-deprecated>` (the old
63
+
argument being ``path``).
64
+
65
+
This is an unfortunate artifact due to historical reasons, which should be
66
+
resolved in future versions as we slowly get rid of the :pypi:`py`
67
+
dependency (see :issue:`9283` for a longer discussion).
68
+
69
+
Due to the ongoing migration of methods like :meth:`~_pytest.Item.reportinfo`
70
+
which still is expected to return a ``py.path.local`` object, nodes still have
71
+
both ``fspath`` (``py.path.local``) and ``path`` (``pathlib.Path``) attributes,
72
+
no matter what argument was used in the constructor. We expect to deprecate the
73
+
``fspath`` attribute in a future release.
59
74
60
75
.. _legacy-path-hooks-deprecated:
61
76
@@ -74,6 +89,16 @@ In order to support the transition from ``py.path.local`` to :mod:`pathlib`, the
74
89
75
90
The accompanying ``py.path.local`` based paths have been deprecated: plugins which manually invoke those hooks should only pass the new ``pathlib.Path`` arguments, and users should change their hook implementations to use the new ``pathlib.Path`` arguments.
76
91
92
+
.. note::
93
+
The name of the :class:`~_pytest.nodes.Node` arguments and attributes,
94
+
:ref:`outlined above <node-ctor-fspath-deprecation>` (the new attribute
95
+
being ``path``) is **the opposite** of the situation for hooks (the old
96
+
argument being ``path``).
97
+
98
+
This is an unfortunate artifact due to historical reasons, which should be
99
+
resolved in future versions as we slowly get rid of the :pypi:`py`
100
+
dependency (see :issue:`9283` for a longer discussion).
0 commit comments