last_failed_paths: improve caching

This commit is contained in:
Daniel Hahler 2019-05-29 23:28:58 +02:00
parent ceb4f3f701
commit 480dd9e6d6
1 changed files with 4 additions and 3 deletions

View File

@ -164,13 +164,14 @@ class LFPlugin(object):
def last_failed_paths(self):
"""Returns a set with all Paths()s of the previously failed nodeids (cached).
"""
result = getattr(self, "_last_failed_paths", None)
if result is None:
try:
return self._last_failed_paths
except AttributeError:
rootpath = Path(self.config.rootdir)
result = {rootpath / nodeid.split("::")[0] for nodeid in self.lastfailed}
result = {x for x in result if x.exists()}
self._last_failed_paths = result
return result
return result
def pytest_ignore_collect(self, path):
"""