Skip to content

Commit c4c780e

Browse files
committed
WIP: last-failed: honor args
Ref: #5624
1 parent 0783030 commit c4c780e

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
@@ -161,8 +161,17 @@ def last_failed_paths(self):
161161
return self._last_failed_paths
162162
except AttributeError:
163163
rootpath = Path(self.config.rootdir)
164-
result = {rootpath / nodeid.split("::")[0] for nodeid in self.lastfailed}
165-
result = {x for x in result if x.exists()}
164+
result = []
165+
abs_args = {
166+
x if Path(x).is_absolute() else rootpath / x for x in self.config.args
167+
}
168+
for nodeid in self.lastfailed:
169+
path = nodeid.split("::")[0]
170+
abs_path = rootpath / path
171+
if not any(str(abs_path).startswith(x) for x in abs_args):
172+
continue
173+
if abs_path.exists():
174+
result.append(abs_path)
166175
self._last_failed_paths = result
167176
return result
168177

0 commit comments

Comments
 (0)