tests: check that PYTEST_ADDOPTS is not processed twice#478
tests: check that PYTEST_ADDOPTS is not processed twice#478nicoddemus merged 2 commits intopytest-dev:masterfrom
Conversation
689d43d to
be1114e
Compare
|
What about this note? I.e. with pytest-xdist it becomes part of the invocation now. |
|
Instead of unsetting it in pytest-xdist, pytest could also skip the env if invocation params are used (https://github.com/pytest-dev/pytest/blob/8db965c401dd46ff9438dd114b538197d0c31c43/src/_pytest/config/__init__.py#L870-L877). While that seems a bit magical, it might be a good/better solution. |
|
@nicoddemus |
That's fine, the note is about the fact that
Not sure what you mean, can you please clarify? |
Actually I think I'm completely wrong here, |
|
I like this, but I think we should investigate parameters layouts We need a alternative to pytest. Main that has the control of all of them at the call site |
This avoids mutating the original list to reflect on InvocationParams, which is supposed to be an immutable snapshot of the state of pytest.main() at the moment of invocation (see pytest-dev/pytest-xdist#478).
This avoids mutating the original list to reflect on InvocationParams, which is supposed to be an immutable snapshot of the state of pytest.main() at the moment of invocation (see pytest-dev/pytest-xdist#478).
|
OK I figure it out, the problem is that def _preparse(self, args, addopts=True):
if addopts:
env_addopts = os.environ.get("PYTEST_ADDOPTS", "")
if len(env_addopts):
args[:] = (
self._validate_args(shlex.split(env_addopts), "via PYTEST_ADDOPTS")
+ args
)That's why The proper fix is to change |
|
After pytest-dev/pytest#6008 is merged, I think we should still get your test in, as it tightens it. |
|
lovely find and fix |
This avoids mutating the original list to reflect on InvocationParams, which is supposed to be an immutable snapshot of the state of pytest.main() at the moment of invocation (see pytest-dev/pytest-xdist#478).
This avoids mutating the original list to reflect on InvocationParams, which is supposed to be an immutable snapshot of the state of pytest.main() at the moment of invocation (see pytest-dev/pytest-xdist#478).
be1114e to
c3b46c4
Compare
|
Amended to keep the test only - expected to pass on pytestfeatures only for now. |
c3b46c4 to
6b13550
Compare
Can we perhaps skip the test if |
|
Yeah, but no hurry I guess. |
6b13550 to
0bb848f
Compare
0bb848f to
dbaa7a5
Compare
Ref: pytest-dev/pytest#6008 Regressed in 953a3f0, uncovering a bug in pytest.
dbaa7a5 to
af31de6
Compare
Since 953a3f0 options are parsed already, e.g. "-v" from
$PYTEST_ADDOPTS, and therefore$PYTEST_ADDOPTSshould be unset forchild processes.