diff --git a/CHANGELOG b/CHANGELOG index b49cea8b8..cd7ec0ca5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,9 @@ NEXT - fix integration of pytest with unittest.mock.patch decorator when it uses the "new" argument. Thanks Nicolas Delaby for test and PR. +- fix issue with detecting conftest files if the arguments contain + "::" node id specifications (copy pasted from "-v" output) + 2.6 ----------------------------------- diff --git a/_pytest/config.py b/_pytest/config.py index 51f178862..80a0c2c26 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -485,6 +485,11 @@ class Conftest(object): testpaths = namespace.file_or_dir foundanchor = False for path in testpaths: + path = str(path) + # remove node-id syntax + i = path.find("::") + if i != -1: + path = path[:i] anchor = current.join(path, abs=1) if exists(anchor): # we found some file object self._try_load_conftest(anchor) diff --git a/testing/test_conftest.py b/testing/test_conftest.py index 96df19550..8bf936dbe 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -237,3 +237,21 @@ def test_fixture_dependency(testdir, monkeypatch): """)) result = testdir.runpytest("sub") result.stdout.fnmatch_lines(["*1 passed*"]) + + +def test_conftest_found_with_double_dash(testdir): + sub = testdir.mkdir("sub") + sub.join("conftest.py").write(py.std.textwrap.dedent(""" + def pytest_addoption(parser): + parser.addoption("--hello-world", action="store_true") + """)) + p = sub.join("test_hello.py") + p.write(py.std.textwrap.dedent(""" + import pytest + def test_hello(found): + assert found == 1 + """)) + result = testdir.runpytest(str(p) + "@2::test_hello", "-h") + result.stdout.fnmatch_lines(""" + *--hello-world* + """)