Only call _collectfile on package instances
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
This commit is contained in:
parent
e1ad1a14af
commit
8c9efd8608
|
@ -482,6 +482,8 @@ class Session(nodes.FSCollector):
|
||||||
self.trace.root.indent -= 1
|
self.trace.root.indent -= 1
|
||||||
|
|
||||||
def _collect(self, arg):
|
def _collect(self, arg):
|
||||||
|
from _pytest.python import Package
|
||||||
|
|
||||||
names = self._parsearg(arg)
|
names = self._parsearg(arg)
|
||||||
argpath = names.pop(0)
|
argpath = names.pop(0)
|
||||||
paths = []
|
paths = []
|
||||||
|
@ -503,7 +505,7 @@ class Session(nodes.FSCollector):
|
||||||
root = self._node_cache[pkginit]
|
root = self._node_cache[pkginit]
|
||||||
else:
|
else:
|
||||||
col = root._collectfile(pkginit)
|
col = root._collectfile(pkginit)
|
||||||
if col:
|
if col and isinstance(col, Package):
|
||||||
root = col[0]
|
root = col[0]
|
||||||
self._node_cache[root.fspath] = root
|
self._node_cache[root.fspath] = root
|
||||||
|
|
||||||
|
|
|
@ -647,7 +647,7 @@ class Test_getinitialnodes(object):
|
||||||
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.parent is None
|
assert col.parent.parent is None
|
||||||
for col in col.listchain():
|
for col in col.listchain():
|
||||||
assert col.config is config
|
assert col.config is config
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue