From bf3b26b3f72d46bf64a2a6c64da03f93f24b47af Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 29 May 2019 22:43:24 +0200 Subject: [PATCH] Fix regression with --lf and non-selected failures --- src/_pytest/cacheprovider.py | 1 + testing/test_cacheprovider.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 3eaf7de28..b194f80b0 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -178,6 +178,7 @@ class LFPlugin(object): """ if ( self.active + and self._previously_failed_count and self.config.getoption("lf") and path.isfile() and self.lastfailed diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 5024701f1..da6a3da49 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -832,6 +832,26 @@ class TestLastFailed(object): ] ) + def test_lastfailed_with_unknown_failure(self, testdir): + testdir.makepyfile( + **{ + "pkg1/test_1.py": """def test_1(): assert 0""", + "pkg1/test_2.py": """def test_2(): pass""", + } + ) + result = testdir.runpytest() + result.stdout.fnmatch_lines(["collected 2 items", "* 1 failed, 1 passed in *"]) + + py.path.local("pkg1/test_1.py").remove() + result = testdir.runpytest("--lf") + result.stdout.fnmatch_lines( + [ + "collected 1 item", + "run-last-failure: 1 known failures not in selected tests", + "* 1 passed in *", + ] + ) + class TestNewFirst(object): def test_newfirst_usecase(self, testdir):