Open roeniss opened 1 year ago
At first glance this Looks like an combination of 2 and 3
Rootdir is used as anchor for testing ids
Definitely a bug, would be interesting to understand what goes on here. Also interesting to think about what it should show...
I brought this bug here because I'm not sure what rootdir actually does. Is there any correct assumption on my thought?
In practice, putting pytest.ini
in 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-reproduce
not /Users/roeniss/tmp/pytest-error-reproduce/settings
.
In practice, putting pytest.ini in a subdir is pretty unusual
I agree on your suggestion. This is a kind of experiment, which is inspired by this: https://dotmeta.org/ . IMHO, pytest.ini
is not that important to reside in root path.
I recommend also setting --rootdir=.
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.
note
I made a repository to reproduce the bug: https://github.com/roeniss/pytest-bug-rootdir
issue
As we can see above,
settings/test/test_hello.py
doesn't exist. I came up with some idea:rootdir
is 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.rootdir
is 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 becausesettings
directory has no test.rootdir
is 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
from the virtual environment you are using