Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of deprecated startdir parameter #278

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

suutari-ai
Copy link
Contributor

@suutari-ai suutari-ai commented Jan 24, 2024

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
Copy link
Collaborator

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
Copy link
Contributor Author

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.

Use the start_path parameter instead of startdir for Pytest 7 or newer,
since Pytest 7 yields 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 Teemu#232
Copy link
Collaborator

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@suutari-ai: Many thanks for the follow-up improvements to your pull request. Much appreciated! I'll merge this now with the intention of shipping this fix at a later date as pytest-sugar 1.0.0 once Pytest 8.0 has been released. That imminent pytest-sugar 1.0.0 release will also serve as a good opportunity to officially drop Python 3.7 support.

@justinmayer justinmayer merged commit 083723b into Teemu:main Jan 24, 2024
4 checks passed
@suutari-ai suutari-ai deleted the fix-deprecated-startdir branch January 25, 2024 13:11
@hugovk hugovk mentioned this pull request Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PytestRemovedIn8Warning for py.path.local
2 participants