Skip to content

Commit 0ca8ef8

Browse files
committed
_get_main_color: skip cache for last item
1 parent 25d6144 commit 0ca8ef8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/_pytest/terminal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ def show_skipped(lines: List[str]) -> None:
10201020
self.write_line(line)
10211021

10221022
def _get_main_color(self) -> Tuple[str, List[str]]:
1023-
if self._main_color is None or self._known_types is None:
1023+
if self._main_color is None or self._known_types is None or self._is_last_item:
10241024
self._set_main_color()
10251025
assert self._main_color
10261026
assert self._known_types

testing/test_terminal.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
RED = r"\x1b\[31m"
2525
GREEN = r"\x1b\[32m"
2626
YELLOW = r"\x1b\[33m"
27+
BOLD = r"\x1b\[1m"
2728
RESET = r"\x1b\[0m"
2829

2930

@@ -1644,6 +1645,19 @@ def test_foobar(i): raise ValueError()
16441645
]
16451646
)
16461647

1648+
# Only xfail should have yellow progress indicator.
1649+
output = testdir.runpytest("test_axfail.py")
1650+
output.stdout.re_match_lines(
1651+
[
1652+
r"test_axfail.py {yellow}x{reset}{yellow} \s+ \[100%\]{reset}".format(
1653+
yellow=YELLOW, reset=RESET
1654+
),
1655+
r"^{yellow}=+ {yellow}{bold}1 xfailed{reset}{yellow} in ".format(
1656+
yellow=YELLOW, bold=BOLD, reset=RESET,
1657+
),
1658+
]
1659+
)
1660+
16471661
def test_count(self, many_tests_files, testdir):
16481662
testdir.makeini(
16491663
"""

0 commit comments

Comments
 (0)