Skip to content

Commit 2c4c57e

Browse files
committed
Revert fspath deprecation
It is not clear yet how we should proceed with this deprecation because `pytest.Item.reportinfo` is public API and returns a `py.path` object, and is not clear how plugins and our examples should handle that. Reverting just the deprecation aspect of pytest-dev#8251 so we can get a 7.0.0 release out. We will reintroduce the deprecation later once we have a clear path moving forward with replacing `reportinfo`. Closes pytest-dev#8445 Closes pytest-dev#8821
1 parent d0bd269 commit 2c4c57e

File tree

6 files changed

+2
-24
lines changed

6 files changed

+2
-24
lines changed

doc/en/deprecations.rst

-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ In order to support the transition to :mod:`pathlib`, the following hooks now re
3333
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.
3434

3535

36-
``Node.fspath`` in favor of ``pathlib`` and ``Node.path``
37-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38-
39-
.. deprecated:: 6.3
40-
41-
As pytest tries to move off `py.path.local <https://py.readthedocs.io/en/latest/path.html>`__ we ported most of the node internals to :mod:`pathlib`.
42-
43-
Pytest will provide compatibility for quite a while.
44-
4536
Diamond inheritance between :class:`pytest.File` and :class:`pytest.Item`
4637
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4738

src/_pytest/deprecated.py

-6
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@
8989
)
9090

9191

92-
NODE_FSPATH = UnformattedWarning(
93-
PytestDeprecationWarning,
94-
"{type}.fspath is deprecated and will be replaced by {type}.path.\n"
95-
"see https://docs.pytest.org/en/latest/deprecations.html#node-fspath-in-favor-of-pathlib-and-node-path",
96-
)
97-
9892
HOOK_LEGACY_PATH_ARG = UnformattedWarning(
9993
PytestDeprecationWarning,
10094
"The ({pylib_path_arg}: py.path.local) argument is deprecated, please use ({pathlib_path_arg}: pathlib.Path)\n"

src/_pytest/fixtures.py

-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
from _pytest.config.argparsing import Parser
5555
from _pytest.deprecated import check_ispytest
5656
from _pytest.deprecated import FILLFUNCARGS
57-
from _pytest.deprecated import NODE_FSPATH
5857
from _pytest.deprecated import YIELD_FIXTURE
5958
from _pytest.mark import Mark
6059
from _pytest.mark import ParameterSet
@@ -520,7 +519,6 @@ def module(self):
520519
@property
521520
def fspath(self) -> LEGACY_PATH:
522521
"""(deprecated) The file system path of the test module which collected this test."""
523-
warnings.warn(NODE_FSPATH.format(type=type(self).__name__), stacklevel=2)
524522
return legacy_path(self.path)
525523

526524
@property

src/_pytest/nodes.py

-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from _pytest.config import Config
2929
from _pytest.config import ConftestImportFailure
3030
from _pytest.deprecated import FSCOLLECTOR_GETHOOKPROXY_ISINITPATH
31-
from _pytest.deprecated import NODE_FSPATH
3231
from _pytest.mark.structures import Mark
3332
from _pytest.mark.structures import MarkDecorator
3433
from _pytest.mark.structures import NodeKeywords
@@ -226,12 +225,10 @@ def __init__(
226225
@property
227226
def fspath(self) -> LEGACY_PATH:
228227
"""(deprecated) returns a legacy_path copy of self.path"""
229-
warnings.warn(NODE_FSPATH.format(type=type(self).__name__), stacklevel=2)
230228
return legacy_path(self.path)
231229

232230
@fspath.setter
233231
def fspath(self, value: LEGACY_PATH) -> None:
234-
warnings.warn(NODE_FSPATH.format(type=type(self).__name__), stacklevel=2)
235232
self.path = Path(value)
236233

237234
@classmethod

testing/python/fixtures.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,7 @@ def test_request_getmodulepath(self, pytester: Pytester) -> None:
967967
(item,) = pytester.genitems([modcol])
968968
req = fixtures.FixtureRequest(item, _ispytest=True)
969969
assert req.path == modcol.path
970-
with pytest.warns(pytest.PytestDeprecationWarning):
971-
assert req.fspath == modcol.fspath
970+
assert req.fspath == modcol.fspath
972971

973972
def test_request_fixturenames(self, pytester: Pytester) -> None:
974973
pytester.makepyfile(

testing/test_collection.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,7 @@ def test_serialization_byid(self, pytester: Pytester) -> None:
614614
items2, hookrec = pytester.inline_genitems(item.nodeid)
615615
(item2,) = items2
616616
assert item2.name == item.name
617-
with pytest.warns(DeprecationWarning):
618-
assert item2.fspath == item.fspath
617+
assert item2.fspath == item.fspath
619618
assert item2.path == item.path
620619

621620
def test_find_byid_without_instance_parents(self, pytester: Pytester) -> None:

0 commit comments

Comments
 (0)