pytest icon indicating copy to clipboard operation
pytest copied to clipboard

[FR] when fixture is not found, but avaliable in siebling conftests, give them as hints

Open RonnyPfannschmidt opened this issue 3 years ago • 2 comments

What's the problem this feature will solve?

when moving some fixtures from a pytest plugin to a conftest, i missed a very specific use in a sibling file

# excerpt of directory structure
mypkg:
  fixtures: fixture was here
  tests:
     conftest.py: fixture is here now
     test_foo.py: uses fixture
  utils:
    tests:
      test_bar: uses fixture

as i was seeing the errors for the missing fixture, i kept reading the last parts of the filenames (tests/... in good old PEBKAC fashion completely missing the fact hat the prefix was indeed different (mypkg/tests vs mypkg/utils/tests)

the error simply told me fixture 'myfixyture' not found + a list of available fixtures, which albeit correct, just fueled my misguided Monday morning focus

Describe the solution you'd like

in addition to the error telling the name i would like to see the additional details displayed

fixture 'myfixture' not found
hint: definitions of 'myfixture' found in 'mypkg/tests/conftest.py' 
>       available fixtures for `mypkg/utils/tests/test_bar.py': ...  

RonnyPfannschmidt avatar Jul 18 '22 11:07 RonnyPfannschmidt

@RonnyPfannschmidt Hi, is this something the Devs are planning to work on?, if not may i try solve this ?

gomri15 avatar Jul 23 '22 20:07 gomri15

@gomri15 feel free to start on this

RonnyPfannschmidt avatar Jul 24 '22 05:07 RonnyPfannschmidt