Skip to content

Commit d80baaa

Browse files
committed
fixup - align summary row correctly and make colors/glyphs globals
1 parent bb92d83 commit d80baaa

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

test/functional/test_runner.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@
2525
import re
2626
import logging
2727

28-
BOLD = ("", "")
28+
# Formatting. Default colors to empty strings.
29+
BOLD, BLUE, RED, GREY = ("", ""), ("", ""), ("", ""), ("", "")
30+
TICK = "✓ "
31+
CROSS = "✖ "
32+
CIRCLE = "○ "
2933
if os.name == 'posix':
3034
# primitive formatting on supported
3135
# terminal via ANSI escape sequences:
3236
BOLD = ('\033[0m', '\033[1m')
37+
BLUE = ('\033[0m', '\033[0;34m')
38+
RED = ('\033[0m', '\033[0;31m')
39+
GREY = ('\033[0m', '\033[1;30m')
3340

3441
TEST_EXIT_PASSED = 0
3542
TEST_EXIT_SKIPPED = 77
@@ -303,7 +310,8 @@ def print_results(test_results, max_len_name, runtime):
303310
test_result.padding = max_len_name
304311
results += str(test_result)
305312

306-
results += BOLD[1] + "\n%s | %s | %s s (accumulated) \n" % ("ALL".ljust(max_len_name), str(all_passed).ljust(7), time_sum) + BOLD[0]
313+
status = TICK + "Passed" if all_passed else CROSS + "Failed"
314+
results += BOLD[1] + "\n%s | %s | %s s (accumulated) \n" % ("ALL".ljust(max_len_name), status.ljust(9), time_sum) + BOLD[0]
307315
results += "Runtime: %s s\n" % (runtime)
308316
print(results)
309317

@@ -373,26 +381,17 @@ def __init__(self, name, status, time):
373381
self.padding = 0
374382

375383
def __repr__(self):
376-
COLOR = ("", "")
377-
if os.name == 'posix':
378-
# primitive formatting on supported
379-
# terminal via ANSI escape sequences:
380-
if self.status == "Passed":
381-
COLOR = ('\033[0m', '\033[0;34m')
382-
elif self.status == "Failed":
383-
COLOR = ('\033[0m', '\033[0;31m')
384-
elif self.status == "Skipped":
385-
COLOR = ('\033[0m', '\033[1;30m')
386-
387-
SYMBOL = " "
388384
if self.status == "Passed":
389-
SYMBOL = "✓ "
385+
color = BLUE
386+
glyph = TICK
390387
elif self.status == "Failed":
391-
SYMBOL = "✖ "
388+
color = RED
389+
glyph = CROSS
392390
elif self.status == "Skipped":
393-
SYMBOL = "○ "
391+
color = GREY
392+
glyph = CIRCLE
394393

395-
return COLOR[1] + "%s | %s%s | %s s\n" % (self.name.ljust(self.padding), SYMBOL, self.status.ljust(7), self.time) + COLOR[0]
394+
return color[1] + "%s | %s%s | %s s\n" % (self.name.ljust(self.padding), glyph, self.status.ljust(7), self.time) + color[0]
396395

397396

398397
def check_script_list(src_dir):

0 commit comments

Comments
 (0)