diff options
author | 2011-08-12 00:06:39 +0200 | |
---|---|---|
committer | 2011-08-12 00:06:39 +0200 | |
commit | 150922e396994a0c595cab38af54927474543f57 (patch) | |
tree | 95604f8660b8eca0c7612b0c4f80f2b951c87f69 | |
parent | FIXUP! (diff) | |
download | pms-test-suite-150922e396994a0c595cab38af54927474543f57.tar.gz pms-test-suite-150922e396994a0c595cab38af54927474543f57.tar.bz2 pms-test-suite-150922e396994a0c595cab38af54927474543f57.zip |
HTML output: split assertion names into (prefix, realname).
-rw-r--r-- | pmstestsuite/output/html.py | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/pmstestsuite/output/html.py b/pmstestsuite/output/html.py index 78599db..abcd5af 100644 --- a/pmstestsuite/output/html.py +++ b/pmstestsuite/output/html.py @@ -3,6 +3,8 @@ # Released under the terms of the 2-clause BSD license. from collections import defaultdict +from gentoopm.util import ABCObject +from abc import abstractmethod from pmstestsuite.output import OutputModule @@ -87,12 +89,24 @@ class HTMLOutput(OutputModule): for pm in sorted(pms, key = lambda pm: mypms.index(pm)): yield (pm, pms[pm]) - class HTMLElem(object): + class HTMLElem(ABCObject): + @abstractmethod + def set_rowspan(self, rowspan): + pass + + @abstractmethod + def __str__(self): + pass + + class TD(HTMLElem): _elem = 'td' - def __init__(self, text): + def __init__(self, text, colspan = 1): self._attrs = [] self._text = text + self._colspan = colspan + if colspan != 1: + self._attrs.append('colspan="%d"' % colspan) def set_rowspan(self, rowspan): if rowspan != 1: @@ -102,20 +116,14 @@ class HTMLOutput(OutputModule): return '<%s>%s</%s>' % (' '.join([self._elem] + self._attrs), self._text, self._elem) - class TH(HTMLElem): + class TH(TD): _elem = 'th' - def __init__(self, text, colspan = 1): - HTMLElem.__init__(self, text) - self._colspan = colspan - if colspan != 1: - self._attrs.append('colspan="%d"' % colspan) - - class ValCell(HTMLElem): + class ValCell(TD): _color_class = '' def __init__(self, text): - HTMLElem.__init__(self, text) + TD.__init__(self, text) self._attrs.append('class="value %s"' % self._color_class) class ColorValCell(ValCell): @@ -145,6 +153,9 @@ class HTMLOutput(OutputModule): def __init__(self): pass + def set_rowspan(self, rowspan): + pass + def __str__(self): return '' @@ -154,14 +165,14 @@ class HTMLOutput(OutputModule): table[0][0] = TH('Test name') table[0][1] = TH('EAPI') - table[0][2] = TH('Assertion') - table[0][3] = TH('Expected') + table[0][2] = TH('Assertion', colspan = 2) + table[0][4] = TH('Expected') for i, pm in enumerate(mypms): - table[0][4 + i*2] = TH(pm.name, colspan = 2) - table[0][5 + i*2] = NoCell() - table[1][4 + i*2] = TH('Actual') - table[1][5 + i*2] = TH('Result') - maxcol = 6 + i*2 + table[0][5 + i*2] = TH(pm.name, colspan = 2) + table[0][6 + i*2] = NoCell() + table[1][5 + i*2] = TH('Actual') + table[1][6 + i*2] = TH('Result') + maxcol = 7 + i*2 row = 2 for cl, tests in _results_by_class(results): @@ -169,16 +180,21 @@ class HTMLOutput(OutputModule): for t in sorted(tests, key = lambda t: t.eapi): table[row][1] = t.eapi test_asserts = [] - col = 4 + col = 5 for pm, r in _sorted_pms(tests[t]): table[row][col+1] = BoolCell(r) for a in r.assertions: if a.name not in test_asserts: test_asserts.append(a.name) crow = row + test_asserts.index(a.name) - table[crow][2] = a.name - table[crow][3] = ValCell(a.expected) - for c in range(4, maxcol, 2): + if a.prefix is not None: + table[crow][2] = a.prefix + table[crow][3] = a.unprefixed_name + else: + table[crow][2] = TD(a.name, colspan = 2) + table[crow][3] = NoCell() + table[crow][4] = ValCell(a.expected) + for c in range(5, maxcol, 2): table[crow][c] = UnknownValCell() else: crow = row + test_asserts.index(a.name) @@ -202,7 +218,7 @@ class HTMLOutput(OutputModule): break if not isinstance(cell, HTMLElem): - cell = HTMLElem(cell) + cell = TD(cell) cell.set_rowspan(rowspan) f.write(str(cell)) f.write('</tr>') |