Skip to content

Commit

Permalink
Fix handling of pkg init and test file via args
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Feb 8, 2019
1 parent ea73246 commit 82a1d6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/_pytest/main.py
Original file line number Diff line number Diff line change
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
11 changes: 11 additions & 0 deletions testing/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,3 +1144,14 @@ def test_nodeid(request):
]
)
assert result.ret == 0


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(str(init), str(p))
result.stdout.fnmatch_lines(["*2 passed in*"])

0 comments on commit 82a1d6a

Please sign in to comment.