| 1 |
import sys |
| 2 |
import unittest |
| 3 |
|
| 4 |
if sys.version_info[0] < 3: |
| 5 |
base_class = unittest._TextTestResult |
| 6 |
else: |
| 7 |
base_class = unittest.TextTestResult |
| 8 |
|
| 9 |
|
| 10 |
class TestResult(base_class): |
| 11 |
def __init__(self, options, *args, **kwargs): |
| 12 |
super().__init__(*args, **kwargs) |
| 13 |
self._options = options |
| 14 |
|
| 15 |
# unittest.TestResult didn't have skipped until 2.7. We need to |
| 16 |
# polyfill it. |
| 17 |
self.skipped = [] |
| 18 |
|
| 19 |
# We have a custom "ignored" result that isn't present in any Python |
| 20 |
# unittest implementation. It is very similar to skipped. It may make |
| 21 |
# sense to map it into skip some day. |
| 22 |
self.ignored = [] |
| 23 |
|
| 24 |
self.times = [] |
| 25 |
self._firststarttime = None |
| 26 |
# Data stored for the benefit of generating xunit reports. |
| 27 |
self.successes = [] |
| 28 |
self.faildata = {} |
| 29 |
|
| 30 |
def addFailure(self, test, reason): |
| 31 |
print("FAILURE!", test, reason) |
| 32 |
|
| 33 |
def addSuccess(self, test): |
| 34 |
print("SUCCESS!", test) |
| 35 |
|
| 36 |
def addError(self, test, err): |
| 37 |
print("ERR!", test, err) |
| 38 |
|
| 39 |
# Polyfill. |
| 40 |
def addSkip(self, test, reason): |
| 41 |
print("SKIP!", test, reason) |
| 42 |
|
| 43 |
def addIgnore(self, test, reason): |
| 44 |
print("IGNORE!", test, reason) |
| 45 |
|
| 46 |
def onStart(self, test): |
| 47 |
print("ON_START!", test) |
| 48 |
|
| 49 |
def onEnd(self): |
| 50 |
print("ON_END!") |
| 51 |
|
| 52 |
def addOutputMismatch(self, test, ret, got, expected): |
| 53 |
return False |
| 54 |
|
| 55 |
def stopTest(self, test, interrupted=False): |
| 56 |
super().stopTest(test) |