Skip to content

Commit

Permalink
tests: check that PYTEST_ADDOPTS is not processed twice
Browse files Browse the repository at this point in the history
Ref: pytest-dev/pytest#6008

Regressed in 953a3f0, uncovering a bug in pytest.
  • Loading branch information
blueyed committed Feb 22, 2020
1 parent 6fd5b56 commit 0bb848f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/478.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression with duplicated arguments via $PYTEST_ADDOPTS in 1.30.0.
9 changes: 6 additions & 3 deletions testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def test_hello(myarg):
assert result.ret


def test_config_initialization(testdir, pytestconfig):
def test_config_initialization(testdir, monkeypatch, pytestconfig):
"""Ensure workers and master are initialized consistently. Integration test for #445"""
if not hasattr(pytestconfig, "invocation_params"):
pytest.skip(
Expand All @@ -599,7 +599,8 @@ def test_config_initialization(testdir, pytestconfig):
testdir.makepyfile(
**{
"dir_a/test_foo.py": """
def test_1(): pass
def test_1(request):
assert request.config.option.verbose == 2
"""
}
)
Expand All @@ -610,8 +611,10 @@ def test_1(): pass
testpaths=dir_a
""",
)
monkeypatch.setenv("PYTEST_ADDOPTS", "-v")
result = testdir.runpytest("-n2", "-c", "myconfig.ini", "-v")
result.stdout.fnmatch_lines(["dir_a/test_foo.py::test_1*"])
result.stdout.fnmatch_lines(["dir_a/test_foo.py::test_1*", "*= 1 passed in *"])
assert result.ret == 0


@pytest.mark.parametrize("when", ["setup", "call", "teardown"])
Expand Down

0 comments on commit 0bb848f

Please sign in to comment.