Skip to content

Commit c4fd461

Browse files
committed
main: better name for _collection_node_cache3
The weird name was due to f396733, now that I understand it a bit better can give it a more descriptive name.
1 parent c225618 commit c4fd461

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/_pytest/main.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,10 @@ def __init__(self, config: Config) -> None:
454454
self._collection_node_cache2 = (
455455
{}
456456
) # type: Dict[Tuple[Type[nodes.Collector], py.path.local], nodes.Collector]
457-
self._collection_node_cache3 = (
457+
458+
# Keep track of any collected collectors in matchnodes paths, so they
459+
# are not collected more than once.
460+
self._collection_matchnodes_cache = (
458461
{}
459462
) # type: Dict[Tuple[Type[nodes.Collector], str], CollectReport]
460463

@@ -652,7 +655,7 @@ def collect(self) -> Iterator[Union[nodes.Item, nodes.Collector]]:
652655
self.trace.root.indent -= 1
653656
self._collection_node_cache1.clear()
654657
self._collection_node_cache2.clear()
655-
self._collection_node_cache3.clear()
658+
self._collection_matchnodes_cache.clear()
656659
self._collection_pkg_roots.clear()
657660

658661
def _collect(
@@ -677,7 +680,6 @@ def _collect(
677680
if col:
678681
if isinstance(col[0], Package):
679682
self._collection_pkg_roots[str(parent)] = col[0]
680-
# Always store a list in the cache, matchnodes expects it.
681683
self._collection_node_cache1[col[0].fspath] = [col[0]]
682684

683685
# If it's a directory argument, recurse and look for any Subpackages.
@@ -761,11 +763,11 @@ def matchnodes(
761763
if not isinstance(node, nodes.Collector):
762764
continue
763765
key = (type(node), node.nodeid)
764-
if key in self._collection_node_cache3:
765-
rep = self._collection_node_cache3[key]
766+
if key in self._collection_matchnodes_cache:
767+
rep = self._collection_matchnodes_cache[key]
766768
else:
767769
rep = collect_one_node(node)
768-
self._collection_node_cache3[key] = rep
770+
self._collection_matchnodes_cache[key] = rep
769771
if rep.passed:
770772
submatching = []
771773
for x in rep.result:

0 commit comments

Comments
 (0)