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

Use tmp_path pytest fixture over tmpdir #2364

Closed
matthewfeickert opened this issue Oct 26, 2023 · 0 comments · Fixed by #2384
Closed

Use tmp_path pytest fixture over tmpdir #2364

matthewfeickert opened this issue Oct 26, 2023 · 0 comments · Fixed by #2384
Labels
chore Other changes that don't modify src or test files help wanted Extra attention is needed / contributions welcome tests pytest

Comments

@matthewfeickert
Copy link
Member

tmp_path is a modern replacement for tmpdir, by the way.

Thanks and noted.

From the pytest docs (https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html#the-tmpdir-and-tmpdir-factory-fixtures):

The tmpdir and tmpdir_factory fixtures are similar to tmp_path and tmp_path_factory, but use/return legacy py.path.local objects rather than standard pathlib.Path objects.

Note

These days, it is preferred to use tmp_path and tmp_path_factory.

In order to help modernize old code bases, one can run pytest with the legacypath plugin disabled:

pytest -p no:legacypath

This will trigger errors on tests using the legacy paths. It can also be permanently set as part of the addopts parameter in the config file.

We'll fix this up in another PR. 👍

Originally posted by @matthewfeickert in #2363 (comment) given feedback from @henryiii

@matthewfeickert matthewfeickert added help wanted Extra attention is needed / contributions welcome tests pytest chore Other changes that don't modify src or test files labels Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Other changes that don't modify src or test files help wanted Extra attention is needed / contributions welcome tests pytest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant