Repository navigation
Open
Labels
topic: collectionrelated to the collection phaserelated to the collection phasetype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
note
I made a repository to reproduce the bug: https://github.com/roeniss/pytest-bug-rootdir
issue
> tree
.
├── settings
│ └── pytest.ini
└── test
└── test_hello.py
> pytest -c settings/pytest.ini
=== test session starts ===
platform darwin -- Python 3.11.4, pytest-7.4.0, pluggy-1.2.0
rootdir: /Users/roeniss/tmp/pytest-error-reproduce/settings
configfile: pytest.ini
collected 1 item
settings/test/test_hello.py . [100%
=== 1 passed in 0.00s ===
As we can see above, settings/test/test_hello.py doesn't exist. I came up with some idea:
rootdiris just a string placeholder for readability. It is set as the configuration's directory by default and does not affect any actual test run. So this is the expected output.rootdiris something that is considered as source root or test root, meaning that this is a real bug. What should happen here is that no test has run becausesettingsdirectory has no test.rootdiris worked but somehow it fallbacks to root path because there is no test in settings or any reason. Then it starts finding test and find it, run, but sadly the output shows wrong directory. So the log-side should be fixed.
I brought this bug here because I'm not sure what rootdir actually does. Is there any correct assumption on my thought?
versions
> pip list
Package Version
---------- -------
iniconfig 2.0.0
packaging 23.1
pip 23.1.2
pluggy 1.2.0
pytest 7.4.0
setuptools 67.6.1
> pytest --version
pytest 7.4.0
> neofetch
'c. roeniss@Roenissui-MacBookAir-2.local
,xNMM. ------------------------------------
.OMMMMo OS: macOS 13.2.1 22D68 arm64
OMMM0, Host: Mac14,2
.;loddo:' loolloddol;. Kernel: 22.3.0
cKMMMMMMMMMMNWMMMMMMMMMM0: Uptime: 5 days, 15 hours, 30 mins
.KMMMMMMMMMMMMMMMMMMMMMMMWd. Packages: 278 (brew)
XMMMMMMMMMMMMMMMMMMMMMMMX. Shell: zsh 5.8.1
;MMMMMMMMMMMMMMMMMMMMMMMM: Resolution: 2048x1152
:MMMMMMMMMMMMMMMMMMMMMMMM: DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX. WM: Rectangle
kMMMMMMMMMMMMMMMMMMMMMMMMWd. Terminal: iTerm2
.XMMMMMMMMMMMMMMMMMMMMMMMMMMk Terminal Font: JetBrainsMono-Regular 11
.XMMMMMMMMMMMMMMMMMMMMMMMMK. CPU: Apple M2
kMMMMMMMMMMMMMMMMMMMMMMd GPU: Apple M2
;KMMMMMMMWXXWMMMMMMMk. Memory: 1487MiB / 8192MiB
.cooc,. .,coo:.
- a detailed description of the bug or problem you are having
- output of
pip listfrom the virtual environment you are using - pytest and operating system versions
- minimal example if possible
Metadata
Metadata
Assignees
Labels
topic: collectionrelated to the collection phaserelated to the collection phasetype: bugproblem that needs to be addressedproblem that needs to be addressed
Activity
RonnyPfannschmidt commentedon Jul 9, 2023
At first glance this Looks like an combination of 2 and 3
Rootdir is used as anchor for testing ids
bluetech commentedon Jul 9, 2023
Definitely a bug, would be interesting to understand what goes on here. Also interesting to think about what it should show...
In practice, putting
pytest.iniin a subdir is pretty unusual, I would recommend putting it directly in your root dir then you'd be walking the beaten path. But if you want to keep-c settings/pytest.ini, I recommend also setting--rootdir=.because pytest derives the default rootdir from the location of the settings file, but in this case you want it to be/Users/roeniss/tmp/pytest-error-reproducenot/Users/roeniss/tmp/pytest-error-reproduce/settings.roeniss commentedon Jul 9, 2023
I agree on your suggestion. This is a kind of experiment, which is inspired by this: https://dotmeta.org/ . IMHO,
pytest.iniis not that important to reside in root path.Indeed, this resolves the problem I saw. This issue is about "why it works even if I didn't set
--rootdir. Please check out my third idea please.