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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# Copyright (c) 2008 Jonathan M. Lange. See LICENSE for details.
"""Helpers for tests."""
import sys
__metaclass__ = type
__all__ = [
'LoggingResult',
]
from testtools import TestResult
try:
raise Exception
except Exception:
an_exc_info = sys.exc_info()
# Deprecated: This classes attributes are somewhat non deterministic which
# leads to hard to predict tests (because Python upstream are changing things.
class LoggingResult(TestResult):
"""TestResult that logs its event to a list."""
def __init__(self, log):
self._events = log
super(LoggingResult, self).__init__()
def startTest(self, test):
self._events.append(('startTest', test))
super(LoggingResult, self).startTest(test)
def stopTest(self, test):
self._events.append(('stopTest', test))
super(LoggingResult, self).stopTest(test)
def addFailure(self, test, error):
self._events.append(('addFailure', test, error))
super(LoggingResult, self).addFailure(test, error)
def addError(self, test, error):
self._events.append(('addError', test, error))
super(LoggingResult, self).addError(test, error)
def addSkip(self, test, reason):
self._events.append(('addSkip', test, reason))
super(LoggingResult, self).addSkip(test, reason)
def addSuccess(self, test):
self._events.append(('addSuccess', test))
super(LoggingResult, self).addSuccess(test)
def startTestRun(self):
self._events.append('startTestRun')
super(LoggingResult, self).startTestRun()
def stopTestRun(self):
self._events.append('stopTestRun')
super(LoggingResult, self).stopTestRun()
def done(self):
self._events.append('done')
super(LoggingResult, self).done()
# Note, the following three classes are different to LoggingResult by
# being fully defined exact matches rather than supersets.
from testtools.testresult.doubles import *
|