Skip to content

Commit

Permalink
WIP: Fix handling of pkg init and test file via args [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Feb 8, 2019
1 parent 5ca8159 commit 7a291b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/_pytest/main.py
Expand Up @@ -592,7 +592,7 @@ def filter_(f):
col = self._node_cache[argpath]
else:
collect_root = self._pkg_roots.get(argpath.dirname, self)
col = collect_root._collectfile(argpath)
col = collect_root._collectfile(argpath, handle_dupes=False)
if col:
self._node_cache[argpath] = col
m = self.matchnodes(col, names)
Expand Down
15 changes: 15 additions & 0 deletions testing/test_collection.py
Expand Up @@ -1157,3 +1157,18 @@ def test_collectignore_via_conftest(testdir, monkeypatch):

result = testdir.runpytest()
assert result.ret == EXIT_NOTESTSCOLLECTED


def test_collect_pkg_init_and_file_in_args(testdir):
subdir = testdir.mkdir("sub")
init = subdir.ensure("__init__.py")
init.write("def test_init(): pass")
p = subdir.ensure("test_file.py")
p.write("def test_file(): pass")

result = testdir.runpytest("-v", str(init), str(p), str(p))
result.stdout.fnmatch_lines([
"sub/__init__.py PASSED*",
"sub/test_file.py PASSED*",
"*2 passed in*",
])

0 comments on commit 7a291b7

Please sign in to comment.