Merge pull request #3846 from nicoddemus/issue-3843

Fix collection error when tests is specified with --doctest-modules
This commit is contained in:
Bruno Oliveira 2018-08-22 08:17:07 -03:00 committed by GitHub
commit 2137e2b15b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -0,0 +1 @@
Fix collection error when specifying test functions directly in the command line using ``test.py::test`` syntax together with ``--doctest-module``.

View File

@ -625,11 +625,12 @@ class Session(nodes.FSCollector):
resultnodes.append(node) resultnodes.append(node)
continue continue
assert isinstance(node, nodes.Collector) assert isinstance(node, nodes.Collector)
if node.nodeid in self._node_cache: key = (type(node), node.nodeid)
rep = self._node_cache[node.nodeid] if key in self._node_cache:
rep = self._node_cache[key]
else: else:
rep = collect_one_node(node) rep = collect_one_node(node)
self._node_cache[node.nodeid] = rep self._node_cache[key] = rep
if rep.passed: if rep.passed:
has_matched = False has_matched = False
for x in rep.result: for x in rep.result:

View File

@ -660,6 +660,16 @@ class TestInvocationVariants(object):
["*test_world.py::test_other*PASSED*", "*1 passed*"] ["*test_world.py::test_other*PASSED*", "*1 passed*"]
) )
def test_invoke_test_and_doctestmodules(self, testdir):
p = testdir.makepyfile(
"""
def test():
pass
"""
)
result = testdir.runpytest(str(p) + "::test", "--doctest-modules")
result.stdout.fnmatch_lines(["*1 passed*"])
@pytest.mark.skipif(not hasattr(os, "symlink"), reason="requires symlinks") @pytest.mark.skipif(not hasattr(os, "symlink"), reason="requires symlinks")
def test_cmdline_python_package_symlink(self, testdir, monkeypatch): def test_cmdline_python_package_symlink(self, testdir, monkeypatch):
""" """