Skip to content

Commit

Permalink
Better the fix for pytest-dev#3742.
Browse files Browse the repository at this point in the history
  • Loading branch information
turturica authored and turturica committed Aug 10, 2018
1 parent d0bd01b commit 417c742
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/_pytest/main.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -505,8 +505,9 @@ def _collect(self, arg):
root = self._node_cache[pkginit] root = self._node_cache[pkginit]
else: else:
col = root._collectfile(pkginit) col = root._collectfile(pkginit)
if col and isinstance(col, Package): if col:
root = col[0] if isinstance(col[0], Package):
root = col[0]
self._node_cache[root.fspath] = root self._node_cache[root.fspath] = root


# If it's a directory argument, recurse and look for any Subpackages. # If it's a directory argument, recurse and look for any Subpackages.
Expand Down
2 changes: 1 addition & 1 deletion testing/test_collection.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def test_pkgfile(self, testdir):
col = testdir.getnode(config, x) col = testdir.getnode(config, x)
assert isinstance(col, pytest.Module) assert isinstance(col, pytest.Module)
assert col.name == "x.py" assert col.name == "x.py"
assert col.parent.parent is None assert col.parent.parent.parent is None
for col in col.listchain(): for col in col.listchain():
assert col.config is config assert col.config is config


Expand Down

0 comments on commit 417c742

Please sign in to comment.