77 with contextlib.suppress(json.JSONDecodeError): |
77 with contextlib.suppress(json.JSONDecodeError): |
78 return json.loads(versionsStr) |
78 return json.loads(versionsStr) |
79 |
79 |
80 return {} |
80 return {} |
81 |
81 |
|
82 def hasCoverage(self, interpreter): |
|
83 """ |
|
84 Public method to get the test framework version and version information |
|
85 of its installed plugins. |
|
86 |
|
87 @param interpreter interpreter to be used for the test |
|
88 @type str |
|
89 @return flag indicating the availability of coverage functionality |
|
90 @rtype bool |
|
91 """ |
|
92 return True |
|
93 |
82 def createArguments(self, config): |
94 def createArguments(self, config): |
83 """ |
95 """ |
84 Public method to create the arguments needed to start the test process. |
96 Public method to create the arguments needed to start the test process. |
85 |
97 |
86 @param config configuration for the test execution |
98 @param config configuration for the test execution |
116 if config.failedOnly: |
128 if config.failedOnly: |
117 args.append("--failed-only") |
129 args.append("--failed-only") |
118 if config.testFilename: |
130 if config.testFilename: |
119 args.append(config.testFilename) |
131 args.append(config.testFilename) |
120 args.extend(self.__testWidget.getFailedTests()) |
132 args.extend(self.__testWidget.getFailedTests()) |
121 |
133 elif config.testFilename: |
122 elif config.testFilename and config.testName: |
|
123 args.append(config.testFilename) |
134 args.append(config.testFilename) |
124 args.append(config.testName) |
135 args.append(config.testName if config.testName else "suite") |
125 |
136 |
126 return args |
137 return args |
127 |
138 |
128 def start(self, config, pythonpath): |
139 def start(self, config, pythonpath): |
129 """ |
140 """ |
176 ) |
187 ) |
177 |
188 |
178 # test result |
189 # test result |
179 elif data["event"] == "result": |
190 elif data["event"] == "result": |
180 filename, lineno = None, None |
191 filename, lineno = None, None |
181 tracebackLines = [] |
192 tracebackLines = data.get("traceback", "").splitlines() |
182 if "traceback" in data: |
193 if tracebackLines: |
183 # get the error info |
|
184 tracebackLines = data["traceback"].splitlines() |
|
185 # find the last entry matching the pattern |
194 # find the last entry matching the pattern |
186 for index in range(len(tracebackLines) - 1, -1, -1): |
195 for index in range(len(tracebackLines) - 1, -1, -1): |
187 fmatch = re.search(r'File "(.*?)", line (\d*?),.*', |
196 fmatch = re.search(r'File "(.*?)", line (\d*?),.*', |
188 tracebackLines[index]) |
197 tracebackLines[index]) |
189 if fmatch: |
198 if fmatch: |
190 break |
199 break |
191 if fmatch: |
200 if fmatch: |
192 filename = fmatch.group(1) |
201 filename = fmatch.group(1) |
193 lineno = int(fmatch.group(2)) |
202 lineno = int(fmatch.group(2)) |
194 |
203 |
195 if "shortmsg" in data: |
204 message = data.get("shortmsg", "") |
196 message = data["shortmsg"] |
205 if not message and tracebackLines: |
197 elif tracebackLines: |
|
198 message = tracebackLines[-1].split(":", 1)[1].strip() |
206 message = tracebackLines[-1].split(":", 1)[1].strip() |
199 else: |
|
200 message = "" |
|
201 |
207 |
202 self.testResult.emit(TestResult( |
208 self.testResult.emit(TestResult( |
203 category=self.__statusCategoryMapping[data["status"]], |
209 category=self.__statusCategoryMapping[data["status"]], |
204 status=self.__statusDisplayMapping[data["status"]], |
210 status=self.__statusDisplayMapping[data["status"]], |
205 name=data["name"], |
211 name=data["name"], |
206 id=data["id"], |
212 id=data["id"], |
207 description=data["description"], |
213 description=data["description"], |
208 message=message, |
214 message=message, |
209 extra=tracebackLines, |
215 extra=tracebackLines, |
210 duration=( |
216 duration=data.get("duration_ms", None), |
211 data["duration_ms"] if "duration_ms" in data else None |
|
212 ), |
|
213 filename=filename, |
217 filename=filename, |
214 lineno=lineno, |
218 lineno=lineno, |
215 subtestResult=data["subtest"] if "subtest" in data else False |
219 subtestResult=data.get("subtest", False) |
216 )) |
220 )) |
217 |
221 |
218 # test run finished |
222 # test run finished |
219 elif data["event"] == "finished": |
223 elif data["event"] == "finished": |
220 self.testRunFinished.emit(data["tests"], data["duration_s"]) |
224 self.testRunFinished.emit(data["tests"], data["duration_s"]) |