I have been using the path.py library in my Python projects for path manipulations and recently encountered issues when running tests with the latest versions of pytest.
ERROR test - pytest.PytestRemovedIn8Warning: The (fspath: py.path.local) argument to BlackItem is deprecated. Please use the (path: ...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!
I understand that pytest has been transitioning from py.path.local to pathlib.Path, but it's unclear whether this transition mandates that all path manipulations in my tests also need to be migrated to pathlib.
My question : is the migration to pathlib in the context of pytest testing environments mandatory, or just recommended?
Updating pytest: I updated pytest to the latest version to ensure that all new features and fixes are applied. I expected that the update might resolve any deprecation warnings related to path handling, but after updating, the warnings remained.
Using pathlib in a test file: I tried replacing instances of path.py with pathlib.Path in one of my test files to see if this would eliminate the warnings. I expected that this change would make the warnings go away and that my tests would still pass. However, while the deprecation warnings were reduced, some tests started failing due to differences in how pathlib and path.py handle path operations. ( which is normal as I did not fully migrate to pathlib)
Judging from the error message, they are aiming to drop
path.pyparameters inpytest8 and the deprecations have started inpytest7. So it's probably a good idea to start the adoptingpathlibin your own test suite as well, unless you want to freeze pathlib to a previous version.fspath argument for Node constructors replaced with pathlib.Path
Some related discussion on GitHub: pytest 7: path vs. fspath, pathlib vs. py.path