74 |
74 |
75 self.__currentTestStatus.update({ |
75 self.__currentTestStatus.update({ |
76 "status": "error", |
76 "status": "error", |
77 "traceback": tracebackLines, |
77 "traceback": tracebackLines, |
78 }) |
78 }) |
|
79 |
|
80 def addSkip(self, test, reason): |
|
81 """ |
|
82 Public method called if a test was skipped. |
|
83 |
|
84 @param test reference to the test object |
|
85 @type TestCase |
|
86 @param reason reason for skipping the test |
|
87 @type str |
|
88 """ |
|
89 super().addSkip(test, reason) |
|
90 |
|
91 self.__currentTestStatus.update({ |
|
92 "status": "skipped", |
|
93 "shortmsg": reason, |
|
94 }) |
|
95 |
|
96 def addExpectedFailure(self, test, err): |
|
97 """ |
|
98 Public method called if a test failed expected. |
|
99 |
|
100 @param test reference to the test object |
|
101 @type TestCase |
|
102 @param err tuple containing the exception data like sys.exc_info |
|
103 (exception type, exception instance, traceback) |
|
104 @type tuple |
|
105 """ |
|
106 super().addExpectedFailure(test, err) |
|
107 tracebackLines = self._exc_info_to_string(err, test) |
|
108 |
|
109 self.__currentTestStatus.update({ |
|
110 "status": "expected failure", |
|
111 "traceback": tracebackLines, |
|
112 }) |
|
113 |
|
114 def addUnexpectedSuccess(self, test): |
|
115 """ |
|
116 Public method called if a test succeeded expectedly. |
|
117 |
|
118 @param test reference to the test object |
|
119 @type TestCase |
|
120 """ |
|
121 super().addUnexpectedSuccess(test) |
|
122 |
|
123 self.__currentTestStatus["status"] = "unexpected success" |
79 |
124 |
80 def addSubTest(self, test, subtest, err): |
125 def addSubTest(self, test, subtest, err): |
81 """ |
126 """ |
82 Public method called for each subtest to record its result. |
127 Public method called for each subtest to record its result. |
83 |
128 |
96 "failure" |
141 "failure" |
97 if issubclass(err[0], test.failureException) else |
142 if issubclass(err[0], test.failureException) else |
98 "error" |
143 "error" |
99 ) |
144 ) |
100 |
145 |
101 self.__currentTestStatus.update({ |
146 # record the last subtest fail status as the overall status |
|
147 self.__currentTestStatus["status"] = status |
|
148 |
|
149 self.__writer.write({ |
|
150 "event": "result", |
102 "status": status, |
151 "status": status, |
103 "name": str(subtest), |
152 "name": str(subtest), |
|
153 "id": subtest.id(), |
|
154 "description": subtest.shortDescription(), |
104 "traceback": tracebackLines, |
155 "traceback": tracebackLines, |
|
156 "subtest": True, |
105 }) |
157 }) |
106 |
158 |
107 if self.failfast: |
159 if self.failfast: |
108 self.stop() |
160 self.stop() |
109 |
161 else: |
110 def addSkip(self, test, reason): |
162 self.__writer.write({ |
111 """ |
163 "event": "result", |
112 Public method called if a test was skipped. |
164 "status": "success", |
113 |
165 "name": str(subtest), |
114 @param test reference to the test object |
166 "id": subtest.id(), |
115 @type TestCase |
167 "description": subtest.shortDescription(), |
116 @param reason reason for skipping the test |
168 "subtest": True, |
117 @type str |
169 }) |
118 """ |
|
119 super().addSkip(test, reason) |
|
120 |
|
121 self.__currentTestStatus.update({ |
|
122 "status": "skipped", |
|
123 "shortmsg": reason, |
|
124 }) |
|
125 |
|
126 def addExpectedFailure(self, test, err): |
|
127 """ |
|
128 Public method called if a test failed expected. |
|
129 |
|
130 @param test reference to the test object |
|
131 @type TestCase |
|
132 @param err tuple containing the exception data like sys.exc_info |
|
133 (exception type, exception instance, traceback) |
|
134 @type tuple |
|
135 """ |
|
136 super().addExpectedFailure(test, err) |
|
137 tracebackLines = self._exc_info_to_string(err, test) |
|
138 |
|
139 self.__currentTestStatus.update({ |
|
140 "status": "expected failure", |
|
141 "traceback": tracebackLines, |
|
142 }) |
|
143 |
|
144 def addUnexpectedSuccess(self, test): |
|
145 """ |
|
146 Public method called if a test succeeded expectedly. |
|
147 |
|
148 @param test reference to the test object |
|
149 @type TestCase |
|
150 """ |
|
151 super().addUnexpectedSuccess(test) |
|
152 |
|
153 self.__currentTestStatus["status"] = "unexpected success" |
|
154 |
170 |
155 def startTest(self, test): |
171 def startTest(self, test): |
156 """ |
172 """ |
157 Public method called at the start of a test. |
173 Public method called at the start of a test. |
158 |
174 |