Skip to content

Commit

Permalink
added GUI support for skipped tests, fixes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
timbertson committed Mar 19, 2012
1 parent 0b7936b commit abc40c5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
24 changes: 14 additions & 10 deletions autonose/ui/shared/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ def __init__(self):
self.reset()

def reset(self):
self.ran = self.failures = self.errors = 0
self.ran = self.failures = self.errors = self.skipped = 0

def finish(self): pass

def __str__(self):
html = '<a href="#">#</a> ran <span class="tests">%s tests</span>' % (self.ran,)
if self.failures or self.errors:
html += ' ('
if self.failures:
html += '<span class="failures">%s failures</span>' % (self.failures,)
if self.errors:
html += ", "
if self.errors:
html += '<span class="errors">%s errors</span>' % (self.errors,)
html += ')'
supplementary = [
('failures', self.failures),
('errors', self.errors),
('skipped', self.skipped)
]
relevant_supps = list(filter(lambda x: x[-1] > 0, supplementary))
def render_supp(supp):
name, num = supp
return '<span class="{name}">{num} {name}</span>'.format(name=name, num=num)
if relevant_supps:
html += ' (' + (', '.join(map(render_supp, relevant_supps))) + ')'
return html

class Status(object):
Expand Down Expand Up @@ -195,6 +197,8 @@ def test_complete(self, test):
self.summary.failures += 1
elif test.state == error:
self.summary.errors += 1
elif test.state == skip:
self.summary.skipped += 1
elif test.state == success:
del self.tests[test.id]
return
Expand Down
1 change: 1 addition & 0 deletions autonose/ui/shared/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pre, code {
#summary .tests { color: #9e9; }
#summary .failures { color: #e55; }
#summary .errors { color: #eb5; }
#summary .skipped { color: #6ae; }



Expand Down
17 changes: 14 additions & 3 deletions test/ui/shared/page_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ def test_fail_formatting(self):
assert 'failures' not in str(self.summary)
assert 'errors' not in str(self.summary)

def test_error_formatting(self):
self.summary.ran += 5
self.summary.skips += 1
self.assertMatches(string_containing(
'ran <span class="tests">5 tests</span> '
'(<span class="skip">1 skipped</span>)'
), str(self.summary))
assert 'failures' not in str(self.summary)

def test_error_formatting(self):
self.summary.ran += 5
self.summary.errors += 1
Expand All @@ -32,10 +41,12 @@ def test_error_formatting(self):

def test_combination_formatting(self):
self.summary.ran += 5
self.summary.failures += 2
self.summary.failures += 1
self.summary.errors += 2
self.summary.skipped += 3
self.assertMatches(string_containing(
'ran <span class="tests">5 tests</span> '
'(<span class="failures">2 failures</span>, '
'<span class="errors">2 errors</span>)'
'(<span class="failures">1 failures</span>, '
'<span class="errors">2 errors</span>, '
'<span class="skipped">3 skipped</span>)'
), str(self.summary))

0 comments on commit abc40c5

Please sign in to comment.