Skip to content

Commit 006b768

Browse files
committed
fixup! Fix regression with --lf and non-selected failures
1 parent bf3b26b commit 006b768

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/_pytest/cacheprovider.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def last_failed_paths(self):
168168
if result is None:
169169
rootpath = Path(self.config.rootdir)
170170
result = {rootpath / nodeid.split("::")[0] for nodeid in self.lastfailed}
171+
result = {x for x in result if x.exists()}
171172
self._last_failed_paths = result
172173
return result
173174

@@ -176,17 +177,13 @@ def pytest_ignore_collect(self, path):
176177
Ignore this file path if we are in --lf mode and it is not in the list of
177178
previously failed files.
178179
"""
179-
if (
180-
self.active
181-
and self._previously_failed_count
182-
and self.config.getoption("lf")
183-
and path.isfile()
184-
and self.lastfailed
185-
):
186-
skip_it = Path(path) not in self.last_failed_paths()
187-
if skip_it:
188-
self._skipped_files += 1
189-
return skip_it
180+
if self.active and self.config.getoption("lf") and path.isfile():
181+
last_failed_paths = self.last_failed_paths()
182+
if last_failed_paths:
183+
skip_it = Path(path) not in self.last_failed_paths()
184+
if skip_it:
185+
self._skipped_files += 1
186+
return skip_it
190187

191188
def pytest_report_collectionfinish(self):
192189
if self.active and self.config.getoption("verbose") >= 0:

0 commit comments

Comments
 (0)