pytest
pytest copied to clipboard
Allow users to find usages of py.local
What's the problem this feature will solve?
As far as I understand, py (especially py.local) and related fixtures like tempdir should be replace with pathlib and their corresponding fixtures like tmp_path. In large code bases switching is a longer task and requires multiple commits and work of multiple people
Describe the solution you'd like
It would be great if there would be an option to block the usage of these "old" fixtures, e.g. by a "future mode" or a warning which can be changed to an error with warning filters.
With this,
- it is easy to find, where a code change is needed
- after switching to
pathlibonly, future usage is blocked
Alternative Solutions
- Using a linter, which is quite hard tue the dynamic calculation of fixtures
What "related fixtures" do you have in mind? I can only think of tmpdir, tmpdir_factory and testdir (for testing pytest plugins, not loaded by default).
All those are already part of an internal legacypath plugin (#9208), so if all you want is to disable tmpdir and tmpdir_factory, running pytest with -p no:legacypath-tmpdir should do the job (it also works as part of addopts in the config file). Maybe we should document this somewhere though? What do you think, @bluetech?
@The-Compiler exactly these fixtures and the plugin sounds great. Some documentation would be great 😄
Hi,
That's indeed a neat trick to know when modernizing old code bases.
Can I be assigned this documentation improvement for Hacktober fest ?
Based on effects in previous years I think I'd like to opt out of the hacktoberfest
Sorry to read you had a bad experience.
The event has turned into an opt-in mode since last year at least so you should be able to do that without any problem.
In any case, my documentation update offer still holds.