diff --git a/AUTHORS b/AUTHORS index 6bf45b27b..cb207eb71 100644 --- a/AUTHORS +++ b/AUTHORS @@ -47,6 +47,7 @@ Christian Theunert Christian Tismer Christopher Gilling Cyrus Maden +Dhiren Serai Daniel Grana Daniel Hahler Daniel Nuri diff --git a/changelog/3853.trivial.rst b/changelog/3853.trivial.rst new file mode 100644 index 000000000..252d46043 --- /dev/null +++ b/changelog/3853.trivial.rst @@ -0,0 +1 @@ +Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests. diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index dc72512b8..f601d9bec 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -134,15 +134,12 @@ 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: - 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( - count=self._previously_failed_count, suffix=suffix, noun=noun - ) + 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( + count=self._previously_failed_count, suffix=suffix, noun=noun + ) return "run-last-failure: %s" % mode def pytest_runtest_logreport(self, report): diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index cfeb4a0cf..ba3d6f87a 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -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", {}))