Skip to content

Commit 480dd9e

Browse files
committed
last_failed_paths: improve caching
1 parent ceb4f3f commit 480dd9e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/_pytest/cacheprovider.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,14 @@ def __init__(self, config):
164164
def last_failed_paths(self):
165165
"""Returns a set with all Paths()s of the previously failed nodeids (cached).
166166
"""
167-
result = getattr(self, "_last_failed_paths", None)
168-
if result is None:
167+
try:
168+
return self._last_failed_paths
169+
except AttributeError:
169170
rootpath = Path(self.config.rootdir)
170171
result = {rootpath / nodeid.split("::")[0] for nodeid in self.lastfailed}
171172
result = {x for x in result if x.exists()}
172173
self._last_failed_paths = result
173-
return result
174+
return result
174175

175176
def pytest_ignore_collect(self, path):
176177
"""

0 commit comments

Comments
 (0)