From c4fd4616176a685f25ba79249cd78574b4a6fba2 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 21 Aug 2020 17:03:52 +0300 Subject: [PATCH] main: better name for _collection_node_cache3 The weird name was due to f3967333a145d8a793a0ab53ac5e0cb0b6c87cac, now that I understand it a bit better can give it a more descriptive name. --- src/_pytest/main.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 7b5272666..ec069808b 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -454,7 +454,10 @@ class Session(nodes.FSCollector): self._collection_node_cache2 = ( {} ) # type: Dict[Tuple[Type[nodes.Collector], py.path.local], nodes.Collector] - self._collection_node_cache3 = ( + + # Keep track of any collected collectors in matchnodes paths, so they + # are not collected more than once. + self._collection_matchnodes_cache = ( {} ) # type: Dict[Tuple[Type[nodes.Collector], str], CollectReport] @@ -652,7 +655,7 @@ class Session(nodes.FSCollector): self.trace.root.indent -= 1 self._collection_node_cache1.clear() self._collection_node_cache2.clear() - self._collection_node_cache3.clear() + self._collection_matchnodes_cache.clear() self._collection_pkg_roots.clear() def _collect( @@ -677,7 +680,6 @@ class Session(nodes.FSCollector): if col: if isinstance(col[0], Package): self._collection_pkg_roots[str(parent)] = col[0] - # Always store a list in the cache, matchnodes expects it. self._collection_node_cache1[col[0].fspath] = [col[0]] # If it's a directory argument, recurse and look for any Subpackages. @@ -761,11 +763,11 @@ class Session(nodes.FSCollector): if not isinstance(node, nodes.Collector): continue key = (type(node), node.nodeid) - if key in self._collection_node_cache3: - rep = self._collection_node_cache3[key] + if key in self._collection_matchnodes_cache: + rep = self._collection_matchnodes_cache[key] else: rep = collect_one_node(node) - self._collection_node_cache3[key] = rep + self._collection_matchnodes_cache[key] = rep if rep.passed: submatching = [] for x in rep.result: