Skip to content

Commit

Permalink
factor out KNOWN_TYPES
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jan 30, 2020
1 parent 7ab4588 commit 1180aed
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@

REPORT_COLLECTING_RESOLUTION = 0.5

KNOWN_TYPES = (
"failed",
"passed",
"skipped",
"deselected",
"xfailed",
"xpassed",
"warnings",
"error",
)


def _getdimensions():
# Improved version of shutil.get_terminal_size that looks at stdin,
Expand Down Expand Up @@ -1149,20 +1160,18 @@ def _get_main_color(self) -> Tuple[str, List[str]]:

def _set_main_color(self) -> Tuple[str, List[str]]:
stats = self.stats
known_types = (
"failed passed skipped deselected xfailed xpassed warnings error".split()
)
unknown_type_seen = False

unknown_types: List[str] = []
for found_type in stats.keys():
if found_type not in known_types:
if found_type: # setup/teardown reports have an empty key, ignore them
known_types.append(found_type)
unknown_type_seen = True
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_type_seen:
elif "warnings" in stats or "xpassed" in stats or unknown_types:
main_color = "yellow"
elif "passed" in stats or not self._is_last_item:
main_color = "green"
Expand Down

0 comments on commit 1180aed

Please sign in to comment.