From 8bf343d917dd2ef5c7ba35d300279b31fa8c3630 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 18 Jul 2019 19:12:35 +0200 Subject: [PATCH] WIP: last-failed: honor args Ref: https://github.com/pytest-dev/pytest/issues/5624 --- src/_pytest/cacheprovider.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 6e53545d630..ba3a8d6f14c 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -166,8 +166,17 @@ def last_failed_paths(self): 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()} + result = [] + abs_args = { + x if Path(x).is_absolute() else rootpath / x for x in self.config.args + } + for nodeid in self.lastfailed: + path = nodeid.split("::")[0] + abs_path = rootpath / path + if not any(str(abs_path).startswith(x) for x in abs_args): + continue + if abs_path.exists(): + result.append(abs_path) self._last_failed_paths = result return result