main: inline _collect() into collect()
This removes an unhelpful level of indirection and enables some upcoming upcoming simplifications.
This commit is contained in:
parent
eec13ba57e
commit
d0e8b71404
|
@ -637,21 +637,12 @@ class Session(nodes.FSCollector):
|
|||
return items
|
||||
|
||||
def collect(self) -> Iterator[Union[nodes.Item, nodes.Collector]]:
|
||||
for fspath, parts in self._initial_parts:
|
||||
self.trace("processing argument", (fspath, parts))
|
||||
self.trace.root.indent += 1
|
||||
yield from self._collect(fspath, parts)
|
||||
self.trace.root.indent -= 1
|
||||
self._collection_node_cache1.clear()
|
||||
self._collection_node_cache2.clear()
|
||||
self._collection_matchnodes_cache.clear()
|
||||
self._collection_pkg_roots.clear()
|
||||
|
||||
def _collect(
|
||||
self, argpath: py.path.local, names: Sequence[str]
|
||||
) -> Iterator[Union[nodes.Item, nodes.Collector]]:
|
||||
from _pytest.python import Package
|
||||
|
||||
for argpath, names in self._initial_parts:
|
||||
self.trace("processing argument", (argpath, names))
|
||||
self.trace.root.indent += 1
|
||||
|
||||
# Start with a Session root, and delve to argpath item (dir or file)
|
||||
# and stack all Packages found on the way.
|
||||
# No point in finding packages when collecting doctests.
|
||||
|
@ -669,7 +660,9 @@ class Session(nodes.FSCollector):
|
|||
if col:
|
||||
if isinstance(col[0], Package):
|
||||
self._collection_pkg_roots[str(parent)] = col[0]
|
||||
self._collection_node_cache1[col[0].fspath] = [col[0]]
|
||||
self._collection_node_cache1[col[0].fspath] = [
|
||||
col[0]
|
||||
]
|
||||
|
||||
# If it's a directory argument, recurse and look for any Subpackages.
|
||||
# Let the Package collector deal with subnodes, don't collect here.
|
||||
|
@ -718,7 +711,7 @@ class Session(nodes.FSCollector):
|
|||
if not m:
|
||||
report_arg = "::".join((str(argpath), *names))
|
||||
self._notfound.append((report_arg, col))
|
||||
return
|
||||
continue
|
||||
|
||||
# If __init__.py was the only file requested, then the matched node will be
|
||||
# the corresponding Package, and the first yielded item will be the __init__
|
||||
|
@ -733,9 +726,15 @@ class Session(nodes.FSCollector):
|
|||
# file in it, which gets ignored by the default
|
||||
# "python_files" option.
|
||||
pass
|
||||
return
|
||||
continue
|
||||
yield from m
|
||||
|
||||
self.trace.root.indent -= 1
|
||||
self._collection_node_cache1.clear()
|
||||
self._collection_node_cache2.clear()
|
||||
self._collection_matchnodes_cache.clear()
|
||||
self._collection_pkg_roots.clear()
|
||||
|
||||
def matchnodes(
|
||||
self,
|
||||
matching: Sequence[Union[nodes.Item, nodes.Collector]],
|
||||
|
|
Loading…
Reference in New Issue