pytest-dev / pytest-dev/pytest
Confusing interaction between rootdir and pytest.ini
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
From https://github.com/pytest-dev/pytest/issues/6359#issue-540390553:
Unfortunately I agree that the current interaction between rootdir and ini files is far from clear, and someone just looking at
--rootdirwould assume that it should point to the root of your repository/project, and from there on pytest would findpytest.inifiles and start collection, but this is currently not the case.
I've seen more than one issue popping up about this confusion: people assume that --rootdir mydir implies that pytest will look for pytest.ini files and start collection from mydir, which is not the case at all currently.
I think we should change the meaning of --rootdir the option somehow, because I believe it is the main source of confusion, while I don't think it happens when rootdir is found automatically.
An initial proposal:
--rootdir when given:
- Will set
config.rootdirto that value (of course). - Will search from
--rootdirand upwards forpytest.inifiles. - If no paths are given in the command line, it will act like
testpaths, where collection will be assumed to start from--rootdir.
Thoughts?
It is a change in existing behavior, but I think --rootdir is rarely used, and when used people are usually confused by it.
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
Read the referenced issue #6359 and investigate the current --rootdir behavior, including how pytest.ini discovery and collection roots are selected. Resolve the proposed semantics before implementation; done means the behavior is explicitly agreed and matches the resulting --rootdir rules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100