Skip to content

tests: check that PYTEST_ADDOPTS is not processed twice #478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
13 changes: 10 additions & 3 deletions testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,11 @@ def test_hello(myarg):
assert result.ret


def test_config_initialization(testdir, pytestconfig):
@pytest.mark.skipif(
sys.version_info[:2] == (2, 7),
reason="Only available in pytest 5.0+ (Python 3 only)",
)
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 @@ -602,7 +606,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 @@ -613,8 +618,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