Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needless message printed with --failed-first and no failed tests #3853 #3912

Merged
merged 4 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Christian Theunert
Christian Tismer
Christopher Gilling
Cyrus Maden
Dhiren Serai
Daniel Grana
Daniel Hahler
Daniel Nuri
Expand Down
2 changes: 2 additions & 0 deletions changelog/3853.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhirensr I took the liberty of updating the CHANGELOG a bit: we don't need to explicitly write about internal details like which tests were updated for example; those are not interesting for final users, which are the public the CHANGELOG is meant for. 😁


15 changes: 6 additions & 9 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 12 additions & 7 deletions testing/test_cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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", {}))
Expand Down