-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunittestwrapper.py
35 lines (27 loc) · 1020 Bytes
/
unittestwrapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from __future__ import print_function
import unittest
def formatMessage(message):
return "{0}".format(message).replace("\n", "<:LF:>")
class CwTestResult(unittest.TestResult):
# def startTestRun(self):
# print("<DESCRIBE::>Tests")
# super(CwTestResult, self).startTestRun()
#
# def stopTestRun(self):
# print("<COMPLETEDIN::>")
# super(CwTestResult, self).stopTestRun()
def startTest(self, test):
print("<IT::>" + test._testMethodName)
super(CwTestResult, self).startTest(test)
def stopTest(self, test):
print("<COMPLETEDIN::>")
super(CwTestResult, self).stopTest(test)
def addSuccess(self, test):
print("<PASSED::>Test Passed")
super(CwTestResult, self).addSuccess(test)
def addFailure(self, test, err):
print("<FAILED::>" + formatMessage(err[1]))
super(CwTestResult, self).addFailure(test, err)
def addError(self, test, err):
print("<ERROR::>Unhandled Exception: " + formatMessage(err[1]))
super(CwTestResult, self).addError(test, err)