Skip to content

Commit

Permalink
factor out _determine_main_color
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jan 30, 2020
1 parent 1180aed commit f36b9f7
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,27 +1158,27 @@ def _get_main_color(self) -> Tuple[str, List[str]]:
assert self._known_types
return self._main_color, self._known_types

def _set_main_color(self) -> Tuple[str, List[str]]:
def _determine_main_color(self, unknown_type_seen: bool) -> str:
stats = self.stats

unknown_types: List[str] = []
for found_type in stats.keys():
if found_type: # setup/teardown reports have an empty key, ignore them
if found_type not in KNOWN_TYPES and found_type not in unknown_types:
unknown_types.append(found_type)
known_types = list(KNOWN_TYPES) + unknown_types

# main color
if "failed" in stats or "error" in stats:
main_color = "red"
elif "warnings" in stats or "xpassed" in stats or unknown_types:
elif "warnings" in stats or "xpassed" in stats or unknown_type_seen:
main_color = "yellow"
elif "passed" in stats or not self._is_last_item:
main_color = "green"
else:
main_color = "yellow"
self._main_color, self._known_types = main_color, known_types
return main_color, known_types
return main_color

def _set_main_color(self) -> Tuple[str, List[str]]:
unknown_types = [] # type: List[str]
for found_type in self.stats.keys():
if found_type: # setup/teardown reports have an empty key, ignore them
if found_type not in KNOWN_TYPES and found_type not in unknown_types:
unknown_types.append(found_type)
self._known_types = list(KNOWN_TYPES) + unknown_types
self._main_color = self._determine_main_color(bool(unknown_types))
return self._main_color, self._known_types

def build_summary_stats_line(self) -> Tuple[List[Tuple[str, Dict[str, bool]]], str]:
main_color, known_types = self._get_main_color()
Expand Down

0 comments on commit f36b9f7

Please sign in to comment.