Skip to content

Commit

Permalink
only update in pytest_ignore_collect
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jan 10, 2020
1 parent 6c6cfb5 commit 3dda985
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,15 @@ def __init__(self, config):
self.config = config
self.active = config.option.newfirst
self.cached_nodeids = config.cache.get("cache/nodeids", [])
self.cached_fspaths = config.cache.get("cache/fspaths", {})
self.cached_fspaths = config.cache.get(
"cache/fspaths", {}
) # type: Dict[str, Dict]
self.rootdir = Path(self.config.rootdir)

def pytest_collection_modifyitems(
self, session: Session, config: Config, items: List[nodes.Item]
) -> None:
new_items = OrderedDict() # type: OrderedDict[str, nodes.Item]
update_fspath = {} # type: Dict[str, Dict]
if self.active:
other_items = OrderedDict() # type: OrderedDict[str, nodes.Item]
for item in items:
Expand All @@ -297,21 +298,14 @@ def pytest_collection_modifyitems(
else:
other_items[item.nodeid] = item

relfspath = str(Path(item.fspath).relative_to(self.rootdir))
if relfspath not in update_fspath:
update_fspath[relfspath] = {"mtime": item.fspath.mtime()}

items[:] = self._get_increasing_order(
new_items.values()
) + self._get_increasing_order(other_items.values())
else:
for item in items:
if item.nodeid not in self.cached_nodeids:
new_items[item.nodeid] = item
relfspath = str(Path(item.fspath).relative_to(self.rootdir))
if relfspath not in update_fspath:
update_fspath[relfspath] = {"mtime": item.fspath.mtime()}
self.cached_fspaths.update(update_fspath)

self.cached_nodeids.extend(new_items)

keyword = config.option.nodeid_keyword.lstrip()
Expand All @@ -330,7 +324,10 @@ def pytest_ignore_collect(self, path, config):
if ppath.is_dir():
return

relpath = str(ppath.relative_to(self.rootdir))
try:
relpath = str(ppath.relative_to(self.rootdir))
except ValueError:
relpath = str(ppath)

if relpath not in self.cached_fspaths:
# unknown/new: collect, but set mtime
Expand Down

0 comments on commit 3dda985

Please sign in to comment.