From 044d874c5b7d6c139cdb4e702322ad28f020ad7a Mon Sep 17 00:00:00 2001 From: Eric Siegerman Date: Tue, 30 Jun 2015 19:20:25 -0400 Subject: [PATCH] If there are warnings, make the status bar yellow Also if we see any statuses the code doesn't know about. --- _pytest/terminal.py | 4 ++++ testing/test_terminal.py | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 57560f94c..35293042f 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -528,10 +528,12 @@ def flatten(l): def build_summary_stats_line(stats): keys = ("failed passed skipped deselected " "xfailed xpassed warnings error").split() + unknown_key_seen = False for key in stats.keys(): if key not in keys: if key: # setup/teardown reports have an empty key, ignore them keys.append(key) + unknown_key_seen = True parts = [] for key in keys: val = stats.get(key, None) @@ -541,6 +543,8 @@ def build_summary_stats_line(stats): if 'failed' in stats or 'error' in stats: color = 'red' + elif 'warnings' in stats or unknown_key_seen: + color = 'yellow' else: color = 'green' diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 877e9b070..9706ca4c4 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -732,11 +732,11 @@ def test_terminal_summary(testdir): ("red", "1 passed, 1 error", {"error": (1,), "passed": (1,)}), # (a status that's not known to the code) - ("green", "1 weird", {"weird": (1,)}), - ("green", "1 passed, 1 weird", {"weird": (1,), "passed": (1,)}), + ("yellow", "1 weird", {"weird": (1,)}), + ("yellow", "1 passed, 1 weird", {"weird": (1,), "passed": (1,)}), - ("green", "1 warnings", {"warnings": (1,)}), - ("green", "1 passed, 1 warnings", {"warnings": (1,), "passed": (1,)}), + ("yellow", "1 warnings", {"warnings": (1,)}), + ("yellow", "1 passed, 1 warnings", {"warnings": (1,), "passed": (1,)}), ("green", "5 passed", {"passed": (1,2,3,4,5)}),