Skip to content

Commit 41bdfab

Browse files
committed
_get_main_color: no yellow ("boring") for non-last item
1 parent 19de5c5 commit 41bdfab

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/_pytest/terminal.py

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

testing/test_terminal.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,11 @@ def test_normal(self, many_tests_files, testdir):
16631663
def test_colored_progress(self, testdir, monkeypatch):
16641664
monkeypatch.setenv("PY_COLORS", "1")
16651665
testdir.makepyfile(
1666+
test_axfail="""
1667+
import pytest
1668+
@pytest.mark.xfail
1669+
def test_axfail(): assert 0
1670+
""",
16661671
test_bar="""
16671672
import pytest
16681673
@pytest.mark.parametrize('i', range(10))
@@ -1687,8 +1692,9 @@ def test_foobar(i): raise ValueError()
16871692
[
16881693
line.format(**RE_COLORS)
16891694
for line in [
1690-
r"test_bar.py ({green}\.{reset}){{10}}{green} \s+ \[ 50%\]{reset}",
1691-
r"test_foo.py ({green}\.{reset}){{5}}{yellow} \s+ \[ 75%\]{reset}",
1695+
r"test_axfail.py {yellow}x{reset}{green} \s+ \[ 4%\]{reset}",
1696+
r"test_bar.py ({green}\.{reset}){{10}}{green} \s+ \[ 52%\]{reset}",
1697+
r"test_foo.py ({green}\.{reset}){{5}}{yellow} \s+ \[ 76%\]{reset}",
16921698
r"test_foobar.py ({red}F{reset}){{5}}{red} \s+ \[100%\]{reset}",
16931699
]
16941700
]

0 commit comments

Comments
 (0)