Skip to content

Commit 689d43d

Browse files
committed
Remove $PYTEST_ADDOPTS with newer pytest
Since 953a3f0 options are parsed already, e.g. "-v" from `$PYTEST_ADDOPTS`, and therefore `$PYTEST_ADDOPTS` should be unset for child processes.
1 parent 79dd52b commit 689d43d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/xdist/remote.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ def setup_config(config, basetemp):
243243

244244
if hasattr(Config, "InvocationParams"):
245245
config = _prepareconfig(args, None)
246+
if "PYTEST_ADDOPTS" in os.environ:
247+
del os.environ["PYTEST_ADDOPTS"]
246248
else:
247249
config = remote_initconfig(option_dict, args)
248250
config.args = args

testing/acceptance_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def test_hello(myarg):
559559
assert result.ret
560560

561561

562-
def test_config_initialization(testdir, pytestconfig):
562+
def test_config_initialization(testdir, monkeypatch, pytestconfig):
563563
"""Ensure workers and master are initialized consistently. Integration test for #445"""
564564
if not hasattr(pytestconfig, "invocation_params"):
565565
pytest.skip(
@@ -568,7 +568,8 @@ def test_config_initialization(testdir, pytestconfig):
568568
testdir.makepyfile(
569569
**{
570570
"dir_a/test_foo.py": """
571-
def test_1(): pass
571+
def test_1(request):
572+
assert request.config.verbose == 1
572573
"""
573574
}
574575
)
@@ -579,6 +580,7 @@ def test_1(): pass
579580
testpaths=dir_a
580581
""",
581582
)
583+
monkeypatch.setenv("PYTEST_ADDOPTS", "-v")
582584
result = testdir.runpytest("-n2", "-c", "myconfig.ini", "-v")
583585
result.stdout.fnmatch_lines(["dir_a/test_foo.py::test_1*"])
584586

0 commit comments

Comments
 (0)