Commit 74259848 authored by Mathieu Giraud's avatar Mathieu Giraud

src/should.py: colorize TestSet.str_status()

parent 388cbfd4
Pipeline #732 passed with stages
in 1 second
......@@ -46,6 +46,11 @@ class ANSI:
def color(col, text):
return CSIm % ANSI.BRIGHT + CSIm % col + text + CSIm % ANSI.RESET
STATUS_COLORS = {
None: ANSI.BLUE,
False: ANSI.RED,
True: ANSI.GREEN,
}
# Modifier parser
......@@ -225,7 +230,7 @@ class TestSet():
echo "hello"
True
>>> s2.str_status()
>>> s2.str_status(colorize = False)
'==> ok - ok:1 total:1'
'''
......@@ -283,12 +288,12 @@ class TestSet():
return self.status
def str_status(self):
def str_status(self, colorize=True):
s = '==> '
s += STATUS[self.status]
s += ' - '
s += ' '.join(['%s:%d' % (STATUS[key], val) for (key, val) in self.stats.items()] + ['total:%s' % sum(self.stats.values())])
return s
return color(STATUS_COLORS[self.status], s) if colorize else s
def __str__(self):
s = ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment