I have a suite of tests that I have loaded using TestLoader\'s (from the unittest module) loadTestsFromModule() method, i.e.,
suite = loader.loadTestsFromModule
Some observations:
__call__(result)
methodTestCase
provides a higher-level interface, allowing test methods to throw a SkipTest
exception to skip themselvesskip
decorators do exactly thisSo you just need to replace the to-be-skipped tests with a custom test that calls addSkip
:
class Skipper(object):
def __init__(self, test, reason):
self.test = test
self.reason = reason
def __call__(self, result):
result.addSkip(self.test, self.reason)