Skip to content

Commit 64f0068

Browse files
authored
Merge pull request #3912 from dhirensr/needless_message
Needless message printed with --failed-first and no failed tests #3853
2 parents a605ad4 + 84a033f commit 64f0068

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Christian Theunert
4747
Christian Tismer
4848
Christopher Gilling
4949
Cyrus Maden
50+
Dhiren Serai
5051
Daniel Grana
5152
Daniel Hahler
5253
Daniel Nuri

changelog/3853.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.

src/_pytest/cacheprovider.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,12 @@ def __init__(self, config):
134134
def pytest_report_collectionfinish(self):
135135
if self.active:
136136
if not self._previously_failed_count:
137-
mode = "run {} (no recorded failures)".format(
138-
self._no_failures_behavior
139-
)
140-
else:
141-
noun = "failure" if self._previously_failed_count == 1 else "failures"
142-
suffix = " first" if self.config.getoption("failedfirst") else ""
143-
mode = "rerun previous {count} {noun}{suffix}".format(
144-
count=self._previously_failed_count, suffix=suffix, noun=noun
145-
)
137+
return None
138+
noun = "failure" if self._previously_failed_count == 1 else "failures"
139+
suffix = " first" if self.config.getoption("failedfirst") else ""
140+
mode = "rerun previous {count} {noun}{suffix}".format(
141+
count=self._previously_failed_count, suffix=suffix, noun=noun
142+
)
146143
return "run-last-failure: %s" % mode
147144

148145
def pytest_runtest_logreport(self, report):

testing/test_cacheprovider.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,7 @@ def test_b2():
414414
)
415415

416416
result = testdir.runpytest(test_a, "--lf")
417-
result.stdout.fnmatch_lines(
418-
[
419-
"collected 2 items",
420-
"run-last-failure: run all (no recorded failures)",
421-
"*2 passed in*",
422-
]
423-
)
417+
result.stdout.fnmatch_lines(["collected 2 items", "*2 passed in*"])
424418

425419
result = testdir.runpytest(test_b, "--lf")
426420
result.stdout.fnmatch_lines(
@@ -617,6 +611,17 @@ def test():
617611
assert self.get_cached_last_failed(testdir) == []
618612
assert result.ret == 0
619613

614+
@pytest.mark.parametrize("quiet", [True, False])
615+
@pytest.mark.parametrize("opt", ["--ff", "--lf"])
616+
def test_lf_and_ff_prints_no_needless_message(self, quiet, opt, testdir):
617+
# Issue 3853
618+
testdir.makepyfile("def test(): pass")
619+
args = [opt]
620+
if quiet:
621+
args.append("-q")
622+
result = testdir.runpytest(*args)
623+
assert "run all" not in result.stdout.str()
624+
620625
def get_cached_last_failed(self, testdir):
621626
config = testdir.parseconfigure()
622627
return sorted(config.cache.get("cache/lastfailed", {}))

0 commit comments

Comments
 (0)