pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Allow users to find usages of py.local

Open kasium opened this issue 3 years ago • 2 comments

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,

  1. it is easy to find, where a code change is needed
  2. after switching to pathlib only, future usage is blocked

Alternative Solutions

  • Using a linter, which is quite hard tue the dynamic calculation of fixtures

kasium avatar Aug 10 '22 09:08 kasium

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 avatar Aug 10 '22 10:08 The-Compiler

@The-Compiler exactly these fixtures and the plugin sounds great. Some documentation would be great 😄

kasium avatar Aug 10 '22 10:08 kasium

Hi,

That's indeed a neat trick to know when modernizing old code bases.

Can I be assigned this documentation improvement for Hacktober fest ?

sgaist avatar Sep 28 '22 22:09 sgaist

Based on effects in previous years I think I'd like to opt out of the hacktoberfest

RonnyPfannschmidt avatar Sep 28 '22 22:09 RonnyPfannschmidt

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.

sgaist avatar Sep 28 '22 22:09 sgaist