Report optional specs/mechs that required a test to be skipped.

This commit is contained in:
Valentin Lorentz
2015-12-20 11:26:30 +01:00
parent 287969248d
commit 95ad6f32d7
3 changed files with 28 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import unittest
import functools
import importlib
from .cases import _IrcTestCase
from .optional_extensions import OptionalityReportingTextTestRunner
from .basecontrollers import BaseClientController, BaseServerController
def main(args):
@ -28,7 +29,7 @@ def main(args):
_IrcTestCase.controllerClass = controller_class
_IrcTestCase.show_io = args.show_io
ts = module.discover()
testRunner = unittest.runner.TextTestRunner()
testRunner = OptionalityReportingTextTestRunner()
testLoader = unittest.loader.defaultTestLoader
testRunner.run(ts)

View File

@ -2,6 +2,7 @@ import ecdsa
import base64
from irctest import cases
from irctest import authentication
from irctest import optional_extensions
from irctest.irc_utils.message_parser import Message
ECDSA_KEY = """
@ -19,7 +20,7 @@ class SaslMechanismCheck:
def checkMechanismSupport(self, mechanism):
if mechanism in self.controller.supported_sasl_mechanisms:
return
self.skipTest('SASL Mechanism not supported: {}'.format(mechanism))
raise optional_extensions.OptionalSaslMechanismNotSupported(mechanism)
class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper,
SaslMechanismCheck):

View File

@ -0,0 +1,24 @@
import unittest
import operator
import itertools
class OptionalExtensionNotSupported(unittest.SkipTest):
def __str__(self):
return 'Unsupported extension: {}'.format(self.args[0])
class OptionalSaslMechanismNotSupported(unittest.SkipTest):
def __str__(self):
return 'Unsupported SASL mechanism: {}'.format(self.args[0])
class OptionalityReportingTextTestRunner(unittest.TextTestRunner):
def run(self, test):
result = super().run(test)
if result.skipped:
print()
print('Some tests were skipped because the following optional'
'specifications/mechanisms are not supported:')
msg_to_tests = itertools.groupby(result.skipped,
key=operator.itemgetter(1))
for (msg, tests) in msg_to_tests:
print('\t{} ({} test(s))'.format(msg, sum(1 for x in tests)))
return result