Skip to content

Commit

Permalink
Only call _collectfile on package instances
Browse files Browse the repository at this point in the history
As discussed in #3751, this feels like a hack, pushing it only so we can
see how it fares on CI and if there are better solutions out there
  • Loading branch information
nicoddemus committed Jul 31, 2018
1 parent e1ad1a1 commit 8c9efd8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,8 @@ def collect(self):
self.trace.root.indent -= 1

def _collect(self, arg):
from _pytest.python import Package

names = self._parsearg(arg)
argpath = names.pop(0)
paths = []
Expand All @@ -503,7 +505,7 @@ def _collect(self, arg):
root = self._node_cache[pkginit]
else:
col = root._collectfile(pkginit)
if col:
if col and isinstance(col, Package):
root = col[0]
self._node_cache[root.fspath] = root

Expand Down
2 changes: 1 addition & 1 deletion testing/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def test_pkgfile(self, testdir):
col = testdir.getnode(config, x)
assert isinstance(col, pytest.Module)
assert col.name == "x.py"
assert col.parent.parent.parent is None
assert col.parent.parent is None
for col in col.listchain():
assert col.config is config

Expand Down

0 comments on commit 8c9efd8

Please sign in to comment.