@@ -332,13 +332,13 @@ class NFPlugin:
332
332
def __init__ (self , config ):
333
333
self .config = config
334
334
self .active = config .option .newfirst
335
- self .cached_nodeids = config .cache .get ("cache/nodeids" , [])
335
+ self .cached_nodeids = set ( config .cache .get ("cache/nodeids" , []) )
336
336
337
337
def pytest_collection_modifyitems (
338
338
self , session : Session , config : Config , items : List [nodes .Item ]
339
339
) -> None :
340
- new_items = OrderedDict () # type: OrderedDict[str, nodes.Item]
341
340
if self .active :
341
+ new_items = OrderedDict () # type: OrderedDict[str, nodes.Item]
342
342
other_items = OrderedDict () # type: OrderedDict[str, nodes.Item]
343
343
for item in items :
344
344
if item .nodeid not in self .cached_nodeids :
@@ -349,11 +349,9 @@ def pytest_collection_modifyitems(
349
349
items [:] = self ._get_increasing_order (
350
350
new_items .values ()
351
351
) + self ._get_increasing_order (other_items .values ())
352
+ self .cached_nodeids .update (new_items )
352
353
else :
353
- for item in items :
354
- if item .nodeid not in self .cached_nodeids :
355
- new_items [item .nodeid ] = item
356
- self .cached_nodeids .extend (new_items )
354
+ self .cached_nodeids .update (item .nodeid for item in items )
357
355
358
356
def _get_increasing_order (self , items ):
359
357
return sorted (items , key = lambda item : item .fspath .mtime (), reverse = True )
@@ -363,7 +361,7 @@ def pytest_sessionfinish(self, session):
363
361
if config .getoption ("cacheshow" ) or hasattr (config , "slaveinput" ):
364
362
return
365
363
366
- config .cache .set ("cache/nodeids" , self .cached_nodeids )
364
+ config .cache .set ("cache/nodeids" , sorted ( self .cached_nodeids ) )
367
365
368
366
369
367
def pytest_addoption (parser ):
0 commit comments