From ad6a093b9217d32f1a39c016ce4a9636d7ed27aa Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Mon, 12 Oct 2020 22:26:29 +1000 Subject: [PATCH] Parse pytest color output correctly. --- eris/termstr.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eris/termstr.py b/eris/termstr.py index 7e86511..dae26a5 100644 --- a/eris/termstr.py +++ b/eris/termstr.py @@ -162,7 +162,7 @@ class TermStr(collections.UserString): codes = part[1:end_index].split(";") previous_code = None for index, code in enumerate(codes): - if code in ["", "0"]: # Normal + if code in ["", "0", "00"]: # Normal is_bold, is_italic, is_underlined = False, False, False fg_color, bg_color = None, None elif code in ["01", "1"]: # bold @@ -171,13 +171,13 @@ class TermStr(collections.UserString): is_italic = True elif code in ["04", "4"]: # underline is_underlined = True - elif len(code) == 2 and code.startswith("3"): # dim fg color + elif 30 <= int(code) <= 37 : # dim fg color fg_color = int(code[1]) - elif len(code) == 2 and code.startswith("4"): # dim bg color + elif 40 <= int(code) <= 47: # dim bg color bg_color = int(code[1]) - elif len(code) == 2 and code.startswith("9"): # high fg color + elif 90 <= int(code) <= 97: # high fg color fg_color = int(code[1]) + 8 - elif len(code) == 3 and code.startswith("10"): # high bg color + elif 100 <= int(code) <= 107: # high bg color bg_color = int(code[2]) + 8 elif code == "5" and previous_code == "38": # simple fg color fg_color = int(codes[index+1])