Fix output of skipped tests.

This commit is contained in:
Valentin Lorentz 2015-12-20 15:11:39 +01:00
parent 7169952a1f
commit d705c4ffbe

View File

@ -1,6 +1,6 @@
import unittest import unittest
import operator import operator
import itertools import collections
class NotImplementedByController(unittest.SkipTest, NotImplementedError): class NotImplementedByController(unittest.SkipTest, NotImplementedError):
def __str__(self): def __str__(self):
@ -22,10 +22,11 @@ class OptionalityReportingTextTestRunner(unittest.TextTestRunner):
result = super().run(test) result = super().run(test)
if result.skipped: if result.skipped:
print() print()
print('Some tests were skipped because the following optional' print('Some tests were skipped because the following optional '
'specifications/mechanisms are not supported:') 'specifications/mechanisms are not supported:')
msg_to_tests = itertools.groupby(result.skipped, msg_to_count = collections.defaultdict(lambda: 0)
key=operator.itemgetter(1)) for (test, msg) in result.skipped:
for (msg, tests) in sorted(msg_to_tests): msg_to_count[msg] += 1
print('\t{} ({} test(s))'.format(msg, sum(1 for x in tests))) for (msg, count) in sorted(msg_to_count.items()):
print('\t{} ({} test(s))'.format(msg, count))
return result return result