mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-devtest
synced 2026-01-15 10:23:32 +01:00
os.TestResults: Beautify dump()
Test results are now output via slog(), and are decorated with a count of failed and total tests. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
82bb65b6c0
commit
86a6939688
1 changed files with 21 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
from texttable import Texttable
|
from texttable import Texttable
|
||||||
|
from pathlib import PurePath
|
||||||
from jwutils.log import *
|
from jwutils.log import *
|
||||||
|
|
||||||
class TestResults: # export
|
class TestResults: # export
|
||||||
|
|
@ -63,6 +64,9 @@ class TestResults: # export
|
||||||
def __fmt_case(self, record):
|
def __fmt_case(self, record):
|
||||||
return record[TestResults.Field.Case].name
|
return record[TestResults.Field.Case].name
|
||||||
|
|
||||||
|
def __fmt_case_short(self, record):
|
||||||
|
return record[TestResults.Field.Case].short_name
|
||||||
|
|
||||||
def __fmt_phase(self, record):
|
def __fmt_phase(self, record):
|
||||||
return record[TestResults.Field.Phase].name
|
return record[TestResults.Field.Phase].name
|
||||||
|
|
||||||
|
|
@ -101,10 +105,23 @@ class TestResults: # export
|
||||||
def addResults(self, results):
|
def addResults(self, results):
|
||||||
self.__records.extend(results.__records)
|
self.__records.extend(results.__records)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __failed(self):
|
||||||
|
return list(filter(lambda rec: (rec[TestResults.Field.Result] is not None), self.__records))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def n_total(self):
|
||||||
|
return len(self.__records)
|
||||||
|
|
||||||
|
@property
|
||||||
def n_failed(self):
|
def n_failed(self):
|
||||||
return len(list(filter(None, [rec[TestResults.Field.Result] for rec in self.__records])))
|
return len(list(filter(None, [rec[TestResults.Field.Result] for rec in self.__records])))
|
||||||
|
|
||||||
def dump(self, args):
|
@property
|
||||||
|
def failed(self):
|
||||||
|
return [self.__fmt_case_short(rec) for rec in self.__failed]
|
||||||
|
|
||||||
|
def dump(self, args, caller=None):
|
||||||
|
|
||||||
t = Texttable(max_width=160)
|
t = Texttable(max_width=160)
|
||||||
|
|
||||||
|
|
@ -143,4 +160,6 @@ class TestResults: # export
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
#slog(DEBUG, rows)
|
#slog(DEBUG, rows)
|
||||||
t.add_rows(rows)
|
t.add_rows(rows)
|
||||||
print(t.draw())
|
if caller is None:
|
||||||
|
caller = get_caller_pos(2)
|
||||||
|
slog_m(NOTICE, t.draw(), caller=caller)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue