Skip to content

Commit 5493562

Browse files
author
Eric Siegerman
committed
Default color is now yellow
Passing tests override that default, making the color green; but several other "boring" statuses (xfailed, xpassed, deselected, skipped) have no effect. Net effect: if only "boring" tests are seen, or no tests at all, the summary bar is yellow.
1 parent 4d454fc commit 5493562

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

_pytest/terminal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,9 @@ def build_summary_stats_line(stats):
545545
color = 'red'
546546
elif 'warnings' in stats or unknown_key_seen:
547547
color = 'yellow'
548-
else:
548+
elif 'passed' in stats:
549549
color = 'green'
550+
else:
551+
color = 'yellow'
550552

551553
return (line, color)

testing/test_terminal.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ def pytest_terminal_summary(terminalreporter):
725725
# dict value, not the actual contents, so tuples of anything
726726
# suffice
727727
728+
# Important statuses -- the highest priority of these always wins
728729
("red", "1 failed", {"failed": (1,)}),
729730
("red", "1 failed, 1 passed", {"failed": (1,), "passed": (1,)}),
730731
@@ -740,23 +741,28 @@ def pytest_terminal_summary(terminalreporter):
740741
741742
("green", "5 passed", {"passed": (1,2,3,4,5)}),
742743
743-
("green", "1 skipped", {"skipped": (1,)}),
744+
745+
# "Boring" statuses. These have no effect on the color of the summary
746+
# line. Thus, if *every* test has a boring status, the summary line stays
747+
# at its default color, i.e. yellow, to warn the user that the test run
748+
# produced no useful information
749+
("yellow", "1 skipped", {"skipped": (1,)}),
744750
("green", "1 passed, 1 skipped", {"skipped": (1,), "passed": (1,)}),
745751
746-
("green", "1 deselected", {"deselected": (1,)}),
752+
("yellow", "1 deselected", {"deselected": (1,)}),
747753
("green", "1 passed, 1 deselected", {"deselected": (1,), "passed": (1,)}),
748754
749-
("green", "1 xfailed", {"xfailed": (1,)}),
755+
("yellow", "1 xfailed", {"xfailed": (1,)}),
750756
("green", "1 passed, 1 xfailed", {"xfailed": (1,), "passed": (1,)}),
751757
752-
("green", "1 xpassed", {"xpassed": (1,)}),
758+
("yellow", "1 xpassed", {"xpassed": (1,)}),
753759
("green", "1 passed, 1 xpassed", {"xpassed": (1,), "passed": (1,)}),
754760
755-
# No tests were found at all
756-
("green", "", {}),
761+
# Likewise if no tests were found at all
762+
("yellow", "", {}),
757763
758764
# Test the empty-key special case
759-
("green", "", {"": (1,)}),
765+
("yellow", "", {"": (1,)}),
760766
("green", "1 passed", {"": (1,), "passed": (1,)}),
761767
762768

0 commit comments

Comments
 (0)