1*16467b97STreehugger Robotimport unittest 2*16467b97STreehugger Robot 3*16467b97STreehugger Robotclass BrokenTest(unittest.TestCase.failureException): 4*16467b97STreehugger Robot def __repr__(self): 5*16467b97STreehugger Robot name, reason = self.args 6*16467b97STreehugger Robot return '%s: %s: %s works now' % ( 7*16467b97STreehugger Robot (self.__class__.__name__, name, reason)) 8*16467b97STreehugger Robot 9*16467b97STreehugger Robot 10*16467b97STreehugger Robotdef broken(reason, *exceptions): 11*16467b97STreehugger Robot '''Indicates a failing (or erroneous) test case fails that should succeed. 12*16467b97STreehugger Robot If the test fails with an exception, list the exception type in args''' 13*16467b97STreehugger Robot def wrapper(test_method): 14*16467b97STreehugger Robot def replacement(*args, **kwargs): 15*16467b97STreehugger Robot try: 16*16467b97STreehugger Robot test_method(*args, **kwargs) 17*16467b97STreehugger Robot except exceptions or unittest.TestCase.failureException: 18*16467b97STreehugger Robot pass 19*16467b97STreehugger Robot else: 20*16467b97STreehugger Robot raise BrokenTest(test_method.__name__, reason) 21*16467b97STreehugger Robot replacement.__doc__ = test_method.__doc__ 22*16467b97STreehugger Robot replacement.__name__ = 'XXX_' + test_method.__name__ 23*16467b97STreehugger Robot replacement.todo = reason 24*16467b97STreehugger Robot return replacement 25*16467b97STreehugger Robot return wrapper 26*16467b97STreehugger Robot 27*16467b97STreehugger Robot 28