From aba55a0fb23f1a5321988cd01f9f13a419105183 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 30 Nov 2015 16:59:12 +0100 Subject: [PATCH] Fix terminal output if no tests were run. Before: ==== in 0.00 seconds ==== After: ==== no tests run in 0.00 seconds ==== --- CHANGELOG | 3 +++ _pytest/terminal.py | 6 +++++- testing/test_terminal.py | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3299513d8..d57c16d06 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,9 @@ - fix #1204: another error when collecting with a nasty __getattr__(). Thanks Florian Bruhin for the PR. +- fix the summary printed when no tests did run. + Thanks Florian Bruhin for the PR. + 2.8.3 ----- diff --git a/_pytest/terminal.py b/_pytest/terminal.py index efc8acc63..8a572e395 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -544,7 +544,11 @@ def build_summary_stats_line(stats): if val: key_name = key_translation.get(key, key) parts.append("%d %s" % (len(val), key_name)) - line = ", ".join(parts) + + if parts: + line = ", ".join(parts) + else: + line = "no tests run" if 'failed' in stats or 'error' in stats: color = 'red' diff --git a/testing/test_terminal.py b/testing/test_terminal.py index cf0554077..0035bbeb0 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -779,10 +779,10 @@ def test_terminal_summary(testdir): ("green", "1 passed, 1 xpassed", {"xpassed": (1,), "passed": (1,)}), # Likewise if no tests were found at all - ("yellow", "", {}), + ("yellow", "no tests run", {}), # Test the empty-key special case - ("yellow", "", {"": (1,)}), + ("yellow", "no tests run", {"": (1,)}), ("green", "1 passed", {"": (1,), "passed": (1,)}),