Fix regression with --lf and non-selected failures

This commit is contained in:
Daniel Hahler 2019-05-29 22:43:24 +02:00
parent 5c5966f62d
commit bf3b26b3f7
2 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -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):