mirror of
https://github.com/progval/irctest.git
synced 2025-04-06 23:39:46 +00:00
Report optional specs/mechs that required a test to be skipped.
This commit is contained in:
@ -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)
|
||||
|
||||
|
@ -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):
|
||||
|
24
irctest/optional_extensions.py
Normal file
24
irctest/optional_extensions.py
Normal 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
|
Reference in New Issue
Block a user