Teemu / pytest-sugar

a plugin for py.test that changes the default look and feel of py.test (e.g. progressbar, show tests that fail instantly)
Other
1.3k stars 73 forks source link

Fix usage of deprecated startdir parameter #278

Closed suutari-ai closed 8 months ago

suutari-ai commented 8 months ago

Use the start_path parameter instead of startdir, since Pytest 7 yield the following deprecation warning if startdir is being used:

site-packages/pytest_sugar.py:279: PytestRemovedIn8Warning:
The (startdir: py.path.local) argument is deprecated, please
use (start_path: pathlib.Path)

Details of the Pytest deprecation can be found from: https://docs.pytest.org/en/latest/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path

Fixes #232

justinmayer commented 8 months ago

This change causes a test failure with one of the existing Pytest 6.2.x-based workflows, so we would either need to change the code to support both 6.x and 7.x, or else drop support for Pytest <7.0. My preference would be to support backwards compatibility in this case.

suutari-ai commented 8 months ago

Thanks for the comments!

I updated the PR to use startdir for pytest 6 or lower and start_path otherwise. Tests should now pass with both pytest 6 and 7. Also tested with pytest 8.0.0rc2 and it seems to work too which is an improvement to the previous code, which failed with pytest 8.