scripts: twister: Don't use match/case statements

Don't use match/case syntax to allow twister to run with
python3 versions < 3.10.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This commit is contained in:
Dmitrii Golovanov 2024-09-18 18:58:31 +02:00 committed by Fabio Baltieri
parent 42020f202f
commit 4cc3134aa1

View File

@ -23,18 +23,17 @@ class TwisterStatus(str, Enum):
@staticmethod
def get_color(status: TwisterStatus) -> str:
match(status):
case TwisterStatus.PASS:
color = Fore.GREEN
case TwisterStatus.SKIP | TwisterStatus.FILTER | TwisterStatus.BLOCK:
color = Fore.YELLOW
case TwisterStatus.FAIL | TwisterStatus.ERROR:
color = Fore.RED
case TwisterStatus.STARTED | TwisterStatus.NONE:
color = Fore.MAGENTA
case _:
color = Fore.RESET
return color
status2color = {
TwisterStatus.PASS: Fore.GREEN,
TwisterStatus.SKIP: Fore.YELLOW,
TwisterStatus.FILTER: Fore.YELLOW,
TwisterStatus.BLOCK: Fore.YELLOW,
TwisterStatus.FAIL: Fore.RED,
TwisterStatus.ERROR: Fore.RED,
TwisterStatus.STARTED: Fore.MAGENTA,
TwisterStatus.NONE: Fore.MAGENTA
}
return status2color[status] if status in status2color else Fore.RESET
# All statuses below this comment can be used for TestCase
BLOCK = 'blocked'