Skip to content

Commit 8bf343d

Browse files
committed
WIP: last-failed: honor args
Ref: #5624
1 parent 63c9ad0 commit 8bf343d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/_pytest/cacheprovider.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,17 @@ def last_failed_paths(self):
166166
return self._last_failed_paths
167167
except AttributeError:
168168
rootpath = Path(self.config.rootdir)
169-
result = {rootpath / nodeid.split("::")[0] for nodeid in self.lastfailed}
170-
result = {x for x in result if x.exists()}
169+
result = []
170+
abs_args = {
171+
x if Path(x).is_absolute() else rootpath / x for x in self.config.args
172+
}
173+
for nodeid in self.lastfailed:
174+
path = nodeid.split("::")[0]
175+
abs_path = rootpath / path
176+
if not any(str(abs_path).startswith(x) for x in abs_args):
177+
continue
178+
if abs_path.exists():
179+
result.append(abs_path)
171180
self._last_failed_paths = result
172181
return result
173182

0 commit comments

Comments
 (0)