From 3035b2724db117264ce49a336b1aed5c201025ef Mon Sep 17 00:00:00 2001 From: dhirensr Date: Thu, 30 Aug 2018 16:01:42 +0530 Subject: [PATCH 1/4] T3853:removed needless message printed with --failed-first,--last-failed and no failed tests --- AUTHORS | 1 + src/_pytest/cacheprovider.py | 15 ++++++--------- testing/test_cacheprovider.py | 19 ++++++++++++------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6bf45b27b85..cb207eb7129 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/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index dc72512b8a7..f601d9bec08 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -134,15 +134,12 @@ def __init__(self, config): 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 cfeb4a0cf39..ba3d6f87ada 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -414,13 +414,7 @@ def test_b2(): ) 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 @@ def test(): 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", {})) From ade01b1f5b197bff47248bacc5325b0c05cf2ab2 Mon Sep 17 00:00:00 2001 From: dhirensr Date: Thu, 30 Aug 2018 16:03:18 +0530 Subject: [PATCH 2/4] T3853:Added changelog file --- changelog/3853.feature.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelog/3853.feature.rst diff --git a/changelog/3853.feature.rst b/changelog/3853.feature.rst new file mode 100644 index 00000000000..5bf739ba49b --- /dev/null +++ b/changelog/3853.feature.rst @@ -0,0 +1,2 @@ +Removed the Needless message printed with --failed-first,--last-failed and no failed tests. +Also added the test in test_cacheprovider.py file and removed 1 option from test which was explictily checking the needless message (run-last-failure: run all (no recorded failures)). From 0183d46275ca9e3c14fe523ac22c5e26e97ea98a Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 30 Aug 2018 19:44:04 -0300 Subject: [PATCH 3/4] Improve CHANGELOG a bit --- changelog/3853.feature.rst | 2 -- changelog/3853.trivial.rst | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 changelog/3853.feature.rst create mode 100644 changelog/3853.trivial.rst diff --git a/changelog/3853.feature.rst b/changelog/3853.feature.rst deleted file mode 100644 index 5bf739ba49b..00000000000 --- a/changelog/3853.feature.rst +++ /dev/null @@ -1,2 +0,0 @@ -Removed the Needless message printed with --failed-first,--last-failed and no failed tests. -Also added the test in test_cacheprovider.py file and removed 1 option from test which was explictily checking the needless message (run-last-failure: run all (no recorded failures)). diff --git a/changelog/3853.trivial.rst b/changelog/3853.trivial.rst new file mode 100644 index 00000000000..fe8a4afb0da --- /dev/null +++ b/changelog/3853.trivial.rst @@ -0,0 +1,2 @@ +Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests. + From 84a033fd97381301adcde2548d1ea169424f67ed Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 30 Aug 2018 19:48:47 -0300 Subject: [PATCH 4/4] Remove extra newline --- changelog/3853.trivial.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/changelog/3853.trivial.rst b/changelog/3853.trivial.rst index fe8a4afb0da..252d4604349 100644 --- a/changelog/3853.trivial.rst +++ b/changelog/3853.trivial.rst @@ -1,2 +1 @@ Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests. -