forked from pytest-dev/pytest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
Node.reportinfo()
return value from py.path
to `str|os.Pat…
…hLike[str]` `reportinfo()` is the last remaining py.path-only code path in pytest, i.e. the last piece holding back py.path deprecation. The problem with it is that plugins/users use it from both sides -- implementing it (returning the value) and using it (using the return value). Dealing with implementers is easy enough -- allow to return `os.PathLike[str]`. But for callers who expect strictly `py.path` this will break and there's not really a good way to provide backward compat for this. From analyzing a corpus of 680 pytest plugins, the vast majority of `reportinfo` appearances are implementations, and the few callers don't actually access the path part of the return tuple. As for test suites that might access `reportinfo` (e.g. using `request.node.reportinfo()` or other ways), that is much harder to survey, but from the ones I searched, I only found case (`pytest_teamcity`, but even then it uses `str(fspath)` so is unlikely to be affected in practice). They are better served with using `node.location` or `node.path` directly. Therefore, just break it and change the return type to `str|os.PathLike[str]`. Refs pytest-dev#7259.
- Loading branch information
Showing
8 changed files
with
28 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The :ref:`Node.reportinfo() <non-python tests>` function first return value type has been expanded from `py.path.local | str` to `os.PathLike[str] | str`. | ||
|
||
Most plugins which refer to `reportinfo()` only define it as part of a custom :class:`pytest.Item` implementation. | ||
Since `py.path.local` is a `os.PathLike[str]`, these plugins are unaffacted. | ||
|
||
Plugins and users which call `reportinfo()`, use the first return value and interact with it as a `py.path.local`, would need to adjust by calling `py.path.local(fspath)`. | ||
Although preferably, avoid the legacy `py.path.local` and use `pathlib.Path`, or use `item.location` or `item.path`, instead. | ||
Note: pytest was not able to provide a deprecation period for this change. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters