From 3c3a1d38d16fb75d72756ad3aedbad87c77ca02c Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Fri, 5 Aug 2011 11:50:50 +0200 Subject: Store test results in a dict instead of main+failed lists. --- pmstestsuite/cli.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'pmstestsuite') 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): -- cgit v1.2.3-65-gdbad