class MyPlugin(nose.plugins.Plugin):
name = 'my-plugin'
def __init__(self):
super(MyPlugin, self).__init__()
self.log = []
def configure(self, options, conf):
super(MyPlugin, self).configure(options, conf)
self.log.append('[MyPlugin] configure')
self.enabled = True
def addSuccess(self, test):
self.log.append('> Test succeed !')
def addError(self, test, err):
self.log.append('> Test error !')
def addFailure(self, test, err):
self.log.append('> Test failed !')
def finalize(self, result):
self.log.append("Ran %d test(s) [%d failure[s], %d error(s)]" %
(result.testsRun, len(result.failures), len(result.errors)))
for line in self.log:
print line
def setOutputStream(self, stream):
class dummy:
def flush(self):
pass
def write(self, *arg):
pass
def writeln(self, *arg):
pass
return dummy()
def startTest(self, test):
self.log.append('[START] %s ' % str(test))
self.log.append(str(test))
def stopTest(self, test):
self.log.append('--\n')