|
15 | 15 | from _pytest.compat import LEGACY_PATH |
16 | 16 | from _pytest.compat import legacy_path |
17 | 17 | from _pytest.deprecated import check_ispytest |
| 18 | +from _pytest.nodes import Node |
18 | 19 | from _pytest.pytester import HookRecorder |
19 | 20 | from _pytest.pytester import RunResult |
20 | 21 | from _pytest.terminal import TerminalReporter |
@@ -389,6 +390,15 @@ def Config__getini_unknown_type( |
389 | 390 | raise ValueError(f"unknown configuration type: {type}", value) |
390 | 391 |
|
391 | 392 |
|
| 393 | +def Node_fspath(self: Node) -> LEGACY_PATH: |
| 394 | + """(deprecated) returns a legacy_path copy of self.path""" |
| 395 | + return legacy_path(self.path) |
| 396 | + |
| 397 | + |
| 398 | +def Node_fspath_set(self: Node, value: LEGACY_PATH) -> None: |
| 399 | + self.path = Path(value) |
| 400 | + |
| 401 | + |
392 | 402 | def pytest_configure(config: pytest.Config) -> None: |
393 | 403 | mp = pytest.MonkeyPatch() |
394 | 404 | config._cleanup.append(mp.undo) |
@@ -432,3 +442,6 @@ def pytest_configure(config: pytest.Config) -> None: |
432 | 442 |
|
433 | 443 | # Add pathlist configuration type. |
434 | 444 | mp.setattr(pytest.Config, "_getini_unknown_type", Config__getini_unknown_type) |
| 445 | + |
| 446 | + # Add Node.fspath property. |
| 447 | + mp.setattr(Node, "fspath", property(Node_fspath, Node_fspath_set), raising=False) |
0 commit comments