165 if config.failedOnly: |
165 if config.failedOnly: |
166 args.append("--last-failed") |
166 args.append("--last-failed") |
167 else: |
167 else: |
168 args.append("--cache-clear") |
168 args.append("--cache-clear") |
169 |
169 |
170 if config.collectCoverage: |
170 if not config.discoverOnly and config.collectCoverage: |
171 args.extend(["--cov=.", "--cov-report="]) |
171 args.extend(["--cov=.", "--cov-report="]) |
172 if not config.eraseCoverage: |
172 if not config.eraseCoverage: |
173 args.append("--cov-append") |
173 args.append("--cov-append") |
174 |
174 |
175 if config.testMarkerExpression: |
175 if config.testMarkerExpression: |
177 args.append(config.testMarkerExpression) |
177 args.append(config.testMarkerExpression) |
178 |
178 |
179 if config.testNamePattern: |
179 if config.testNamePattern: |
180 args.append("-k") |
180 args.append("-k") |
181 args.append(config.testNamePattern) |
181 args.append(config.testNamePattern) |
182 ## |
182 |
183 ##args.append("--collect-only") |
183 if config.discoverOnly: |
184 |
184 args.append("--collect-only") |
185 if config.testFilename: |
185 |
|
186 if config.testCases: |
|
187 args.extend(config.testCases) |
|
188 elif config.testFilename: |
186 if config.testName: |
189 if config.testName: |
187 args.append( |
190 args.append( |
188 "{0}::{1}".format( |
191 "{0}::{1}".format( |
189 config.testFilename, config.testName.replace(".", "::") |
192 config.testFilename, config.testName.replace(".", "::") |
190 ) |
193 ) |
192 else: |
195 else: |
193 args.append(config.testFilename) |
196 args.append(config.testFilename) |
194 |
197 |
195 return args |
198 return args |
196 |
199 |
|
200 def discover(self, config, pythonpath): |
|
201 """ |
|
202 Public method to start the test discovery process. |
|
203 |
|
204 @param config configuration for the test discovery |
|
205 @type TestConfig |
|
206 @param pythonpath list of directories to be added to the Python path |
|
207 @type list of str |
|
208 """ |
|
209 self.reader = EricJsonReader(name="Pytest Reader", parent=self) |
|
210 self.reader.dataReceived.connect(self.__processData) |
|
211 |
|
212 self.__config = config |
|
213 |
|
214 pythonpath.insert(0, os.path.abspath(config.discoveryStart)) |
|
215 self.__rootdir = config.discoveryStart |
|
216 |
|
217 super().discover(config, pythonpath) |
|
218 |
197 def start(self, config, pythonpath): |
219 def start(self, config, pythonpath): |
198 """ |
220 """ |
199 Public method to start the testing process. |
221 Public method to start the testing process. |
200 |
222 |
201 @param config configuration for the test execution |
223 @param config configuration for the test execution |
368 module, name = nodeid.split("::", 1) |
391 module, name = nodeid.split("::", 1) |
369 module = self.__normalizeModuleName(module) |
392 module = self.__normalizeModuleName(module) |
370 name = name.replace("::", ".") |
393 name = name.replace("::", ".") |
371 testname, name = "{0}.{1}".format(module, name).rsplit(".", 1) |
394 testname, name = "{0}.{1}".format(module, name).rsplit(".", 1) |
372 return "{0} ({1})".format(name, testname) |
395 return "{0} ({1})".format(name, testname) |
|
396 |
|
397 def __nodeid2testpath(self, nodeid): |
|
398 """ |
|
399 Private method to convert a nodeid to a test path list. |
|
400 |
|
401 @param nodeid nodeid to be converted |
|
402 @type str |
|
403 @return test path list |
|
404 @rtype list of str |
|
405 """ |
|
406 module, name = nodeid.split("::", 1) |
|
407 module = self.__normalizeModuleName(module) |
|
408 name = "{0}.{1}".format(module, name.replace("::", ".")) |
|
409 return name.split(".") |