fix conftest detection if commandline arguments contain "::" syntax
--HG-- branch : fix_initial_parsing
This commit is contained in:
parent
ba878c6d9d
commit
5ccd3f2fc5
|
@ -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
|
||||
-----------------------------------
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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*
|
||||
""")
|
||||
|
|
Loading…
Reference in New Issue