pytest-dev / pytest-dev/pytest
[FR] when fixture is not found, but avaliable in siebling conftests, give them as hints
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
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': ...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the missing-fixture case using the shown conftest.py and sibling test layout, then trace pytest's fixture-not-found error reporting. Start with the code that builds the available-fixtures message. Done means the error identifies matching fixture definitions in sibling conftest.py files without losing the existing available-fixtures output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100