@@ -454,7 +454,10 @@ def __init__(self, config: Config) -> None:
454
454
self ._collection_node_cache2 = (
455
455
{}
456
456
) # 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 = (
458
461
{}
459
462
) # type: Dict[Tuple[Type[nodes.Collector], str], CollectReport]
460
463
@@ -652,7 +655,7 @@ def collect(self) -> Iterator[Union[nodes.Item, nodes.Collector]]:
652
655
self .trace .root .indent -= 1
653
656
self ._collection_node_cache1 .clear ()
654
657
self ._collection_node_cache2 .clear ()
655
- self ._collection_node_cache3 .clear ()
658
+ self ._collection_matchnodes_cache .clear ()
656
659
self ._collection_pkg_roots .clear ()
657
660
658
661
def _collect (
@@ -677,7 +680,6 @@ def _collect(
677
680
if col :
678
681
if isinstance (col [0 ], Package ):
679
682
self ._collection_pkg_roots [str (parent )] = col [0 ]
680
- # Always store a list in the cache, matchnodes expects it.
681
683
self ._collection_node_cache1 [col [0 ].fspath ] = [col [0 ]]
682
684
683
685
# If it's a directory argument, recurse and look for any Subpackages.
@@ -761,11 +763,11 @@ def matchnodes(
761
763
if not isinstance (node , nodes .Collector ):
762
764
continue
763
765
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 ]
766
768
else :
767
769
rep = collect_one_node (node )
768
- self ._collection_node_cache3 [key ] = rep
770
+ self ._collection_matchnodes_cache [key ] = rep
769
771
if rep .passed :
770
772
submatching = []
771
773
for x in rep .result :
0 commit comments