aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2011-08-05 11:50:50 +0200
committerMichał Górny <mgorny@gentoo.org>2011-08-05 12:05:39 +0200
commit3c3a1d38d16fb75d72756ad3aedbad87c77ca02c (patch)
tree897e60aba5c66925e6b7654d82a04b907b50d456 /pmstestsuite
parentFix test list. (diff)
downloadpms-test-suite-3c3a1d38d16fb75d72756ad3aedbad87c77ca02c.tar.gz
pms-test-suite-3c3a1d38d16fb75d72756ad3aedbad87c77ca02c.tar.bz2
pms-test-suite-3c3a1d38d16fb75d72756ad3aedbad87c77ca02c.zip
Store test results in a dict instead of main+failed lists.
Diffstat (limited to 'pmstestsuite')
-rw-r--r--pmstestsuite/cli.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/pmstestsuite/cli.py b/pmstestsuite/cli.py
index f21c7a9..97dd8db 100644
--- a/pmstestsuite/cli.py
+++ b/pmstestsuite/cli.py
@@ -126,16 +126,17 @@ class PMSTestSuiteCLI(object):
def tests_done(self):
print('-> Checking test results...')
- self.failed = []
+ self.results = {}
for t in self.test_library:
try:
t.check_result(self.pm)
except Exception as e:
outc = 'F' if isinstance(e, AssertionError) else 'E'
- self.failed.append(t)
+ self.results[t] = False
# XXX: store exception details somewhere?
else:
outc = '.'
+ self.results[t] = True
t.clean(self.pm)
print(outc, end='')
print('')
@@ -147,21 +148,21 @@ class PMSTestSuiteCLI(object):
self.all_done()
def all_done(self):
- if not self.failed and not self.verbose:
- print('%d tests completed successfully.' % len(self.test_library))
+ failed = filter(lambda tr: not tr[1], self.results.items())
+ if not failed and not self.verbose:
+ print('%d tests completed successfully.' % len(self.results))
else:
print('%d of %d tests completed successfully, %d failed:'
- % (len(self.test_library) - len(self.failed),
- len(self.test_library), len(self.failed)))
- tl = self.failed if not self.verbose else self.test_library
- for t in tl:
- print('- %s [%s]' % (t,
- 'OK' if t not in self.failed else 'FAILED'))
+ % (len(self.results) - len(failed),
+ len(self.results), len(failed)))
+ tl = failed if not self.verbose else self.results.items()
+ for t, r in tl:
+ print('- %s [%s]' % (t, 'OK' if r else 'FAILED'))
for a in t.assertions:
print('-> %s: %s [%s]' % (a.name, str(a),
'OK' if a else 'FAILED'))
- self.ret = 0 if not self.failed else 1
+ self.ret = 0 if not failed else 1
self.loop.quit()
def start_pm(self):