Skip to content

Commit c91ad61

Browse files
committed
_get_main_color: no yellow ("boring") for non-last item
1 parent 98e4c2a commit c91ad61

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/_pytest/terminal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ def _get_main_color(self) -> Tuple[str, List[str]]:
10271027
main_color = "red"
10281028
elif "warnings" in stats or unknown_type_seen:
10291029
main_color = "yellow"
1030-
elif "passed" in stats:
1030+
elif "passed" in stats or not self._is_last_item:
10311031
main_color = "green"
10321032
else:
10331033
main_color = "yellow"

testing/test_terminal.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,11 @@ def test_normal(self, many_tests_files, testdir):
15631563
def test_colored_progress(self, testdir, monkeypatch):
15641564
monkeypatch.setenv("PY_COLORS", "1")
15651565
testdir.makepyfile(
1566+
test_axfail="""
1567+
import pytest
1568+
@pytest.mark.xfail
1569+
def test_axfail(): assert 0
1570+
""",
15661571
test_bar="""
15671572
import pytest
15681573
@pytest.mark.parametrize('i', range(10))
@@ -1585,10 +1590,13 @@ def test_foobar(i): raise ValueError()
15851590
output = testdir.runpytest()
15861591
output.stdout.re_match_lines(
15871592
[
1588-
r"test_bar.py ({green}\.{reset}){{10}}{green} \s+ \[ 50%\]{reset}".format(
1593+
r"test_axfail.py {yellow}x{reset}{green} \s+ \[ 4%\]{reset}".format(
1594+
yellow=YELLOW, green=GREEN, reset=RESET
1595+
),
1596+
r"test_bar.py ({green}\.{reset}){{10}}{green} \s+ \[ 52%\]{reset}".format(
15891597
green=GREEN, reset=RESET
15901598
),
1591-
r"test_foo.py ({green}\.{reset}){{5}}{yellow} \s+ \[ 75%\]{reset}".format(
1599+
r"test_foo.py ({green}\.{reset}){{5}}{yellow} \s+ \[ 76%\]{reset}".format(
15921600
green=GREEN, reset=RESET, yellow=YELLOW
15931601
),
15941602
r"test_foobar.py ({red}F{reset}){{5}}{red} \s+ \[100%\]{reset}".format(

0 commit comments

Comments
 (0)