Merge pull request #3912 from dhirensr/needless_message

Needless message printed with --failed-first and no failed tests #3853
This commit is contained in:
Bruno Oliveira 2018-08-30 19:51:49 -03:00 committed by GitHub
commit 64f00683f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 16 deletions

View File

@ -47,6 +47,7 @@ Christian Theunert
Christian Tismer
Christopher Gilling
Cyrus Maden
Dhiren Serai
Daniel Grana
Daniel Hahler
Daniel Nuri

View File

@ -0,0 +1 @@
Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.

View File

@ -134,10 +134,7 @@ class LFPlugin(object):
def pytest_report_collectionfinish(self):
if self.active:
if not self._previously_failed_count:
mode = "run {} (no recorded failures)".format(
self._no_failures_behavior
)
else:
return None
noun = "failure" if self._previously_failed_count == 1 else "failures"
suffix = " first" if self.config.getoption("failedfirst") else ""
mode = "rerun previous {count} {noun}{suffix}".format(

View File

@ -414,13 +414,7 @@ class TestLastFailed(object):
)
result = testdir.runpytest(test_a, "--lf")
result.stdout.fnmatch_lines(
[
"collected 2 items",
"run-last-failure: run all (no recorded failures)",
"*2 passed in*",
]
)
result.stdout.fnmatch_lines(["collected 2 items", "*2 passed in*"])
result = testdir.runpytest(test_b, "--lf")
result.stdout.fnmatch_lines(
@ -617,6 +611,17 @@ class TestLastFailed(object):
assert self.get_cached_last_failed(testdir) == []
assert result.ret == 0
@pytest.mark.parametrize("quiet", [True, False])
@pytest.mark.parametrize("opt", ["--ff", "--lf"])
def test_lf_and_ff_prints_no_needless_message(self, quiet, opt, testdir):
# Issue 3853
testdir.makepyfile("def test(): pass")
args = [opt]
if quiet:
args.append("-q")
result = testdir.runpytest(*args)
assert "run all" not in result.stdout.str()
def get_cached_last_failed(self, testdir):
config = testdir.parseconfigure()
return sorted(config.cache.get("cache/lastfailed", {}))