pytest-dev / pytest-dev/pytest
support conftest/ folders
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?
I'm tired of putting so much code in a single tests/conftest.py file.
Describe the solution you'd like
It'd be nice if I could expand conftest.py into a folder, like this:
tests/conftest/__init__.py # loaded instead of conftest.py; imports from sibling modules
tests/conftest/fixtures.py
tests/conftest/setup.py
Alternative Solutions
I could create a different folder, like tests/lib/, add code there, and import that code from tests/conftest.py, but I'd prefer to keep the rest of the tests/ namespace free. For example, the way I organize my tests is identical to how I organize my code. If I have a source file lib/foo.py, I'll create tests for it in tests/lib/test__foo.py. If I used tests/lib/ to instead store setup code for the test suite, that would conflict with the above convention.
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
Start by locating pytest's conftest discovery and loading entry point, then review existing tests for conftest.py behavior. Evaluate how tests/conftest/init.py, fixtures.py, and setup.py would be discovered, including the replacement relationship with tests/conftest.py. Done means the folder form works with sibling imports and existing conftest.py behavior remains intact.
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
- 42/100