Skip to content

Commit 10544c4

Browse files
authored
Merge pull request #3886 from nicoddemus/ff-quiet
Cache now obeys -q when showing summary for --lf and --ff
2 parents a319674 + 47bb53f commit 10544c4

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

changelog/3853.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cache plugin now obeys the ``-q`` flag when ``--last-failed`` and ``--failed-first`` flags are used.

src/_pytest/cacheprovider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __init__(self, config):
132132
self._no_failures_behavior = self.config.getoption("last_failed_no_failures")
133133

134134
def pytest_report_collectionfinish(self):
135-
if self.active:
135+
if self.active and self.config.getoption("verbose") >= 0:
136136
if not self._previously_failed_count:
137137
mode = "run {} (no recorded failures)".format(
138138
self._no_failures_behavior

testing/test_cacheprovider.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,19 @@ def test_lastfailed_creates_cache_when_needed(self, testdir):
559559
testdir.runpytest("-q", "--lf")
560560
assert os.path.exists(".pytest_cache/v/cache/lastfailed")
561561

562+
@pytest.mark.parametrize("quiet", [True, False])
563+
@pytest.mark.parametrize("opt", ["--ff", "--lf"])
564+
def test_lf_and_ff_obey_verbosity(self, quiet, opt, testdir):
565+
testdir.makepyfile("def test(): pass")
566+
args = [opt]
567+
if quiet:
568+
args.append("-q")
569+
result = testdir.runpytest(*args)
570+
if quiet:
571+
assert "run all" not in result.stdout.str()
572+
else:
573+
assert "run all" in result.stdout.str()
574+
562575
def test_xfail_not_considered_failure(self, testdir):
563576
testdir.makepyfile(
564577
"""

0 commit comments

Comments
 (0)