Skip to content

Commit 4cc3134

Browse files
golowanowfabiobaltieri
authored andcommitted
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 <[email protected]>
1 parent 42020f2 commit 4cc3134

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

scripts/pylib/twister/twisterlib/statuses.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,17 @@ def _missing_(cls, value):
2323

2424
@staticmethod
2525
def get_color(status: TwisterStatus) -> str:
26-
match(status):
27-
case TwisterStatus.PASS:
28-
color = Fore.GREEN
29-
case TwisterStatus.SKIP | TwisterStatus.FILTER | TwisterStatus.BLOCK:
30-
color = Fore.YELLOW
31-
case TwisterStatus.FAIL | TwisterStatus.ERROR:
32-
color = Fore.RED
33-
case TwisterStatus.STARTED | TwisterStatus.NONE:
34-
color = Fore.MAGENTA
35-
case _:
36-
color = Fore.RESET
37-
return color
26+
status2color = {
27+
TwisterStatus.PASS: Fore.GREEN,
28+
TwisterStatus.SKIP: Fore.YELLOW,
29+
TwisterStatus.FILTER: Fore.YELLOW,
30+
TwisterStatus.BLOCK: Fore.YELLOW,
31+
TwisterStatus.FAIL: Fore.RED,
32+
TwisterStatus.ERROR: Fore.RED,
33+
TwisterStatus.STARTED: Fore.MAGENTA,
34+
TwisterStatus.NONE: Fore.MAGENTA
35+
}
36+
return status2color[status] if status in status2color else Fore.RESET
3837

3938
# All statuses below this comment can be used for TestCase
4039
BLOCK = 'blocked'

0 commit comments

Comments
 (0)