Skip to content

Commit 4697911

Browse files
committed
_get_main_color: skip cache for last item
Handle random order in test for py35.
1 parent 4935ed4 commit 4697911

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,18 @@ def test_foobar(i): raise ValueError()
17051705
]
17061706
)
17071707

1708+
# Only xfail should have yellow progress indicator.
1709+
result = testdir.runpytest("test_axfail.py")
1710+
result.stdout.re_match_lines(
1711+
[
1712+
line.format(**RE_COLORS)
1713+
for line in [
1714+
r"test_axfail.py {yellow}x{reset}{yellow} \s+ \[100%\]{reset}",
1715+
r"^{yellow}=+ ({yellow}{bold}|{bold}{yellow})1 xfailed{reset}{yellow} in ",
1716+
]
1717+
]
1718+
)
1719+
17081720
def test_count(self, many_tests_files, testdir):
17091721
testdir.makeini(
17101722
"""

0 commit comments

Comments
 (0)