67 failedOnly: bool = False # run failed tests only |
67 failedOnly: bool = False # run failed tests only |
68 collectCoverage: bool = False # coverage collection flag |
68 collectCoverage: bool = False # coverage collection flag |
69 eraseCoverage: bool = False # erase coverage data first |
69 eraseCoverage: bool = False # erase coverage data first |
70 coverageFile: str = "" # name of the coverage data file |
70 coverageFile: str = "" # name of the coverage data file |
71 discoverOnly: bool = False # test discovery only |
71 discoverOnly: bool = False # test discovery only |
|
72 venvName: str = "" # name of the virtual environment |
72 |
73 |
73 |
74 |
74 class TestExecutorBase(QObject): |
75 class TestExecutorBase(QObject): |
75 """ |
76 """ |
76 Base class for test framework specific implementations. |
77 Base class for test framework specific implementations. |
125 @type TestingWidget |
126 @type TestingWidget |
126 """ |
127 """ |
127 super().__init__(testWidget) |
128 super().__init__(testWidget) |
128 |
129 |
129 self.__process = None |
130 self.__process = None |
|
131 self.__debugger = None |
|
132 |
|
133 self._language = "Python3" |
130 |
134 |
131 @classmethod |
135 @classmethod |
132 def isInstalled(cls, interpreter): |
136 def isInstalled(cls, interpreter): |
133 """ |
137 """ |
134 Class method to check whether a test framework is installed. |
138 Class method to check whether a test framework is installed. |
297 self.__process.start(config.interpreter, testArgs) |
301 self.__process.start(config.interpreter, testArgs) |
298 running = self.__process.waitForStarted() |
302 running = self.__process.waitForStarted() |
299 if not running: |
303 if not running: |
300 raise RuntimeError("Test process did not start.") |
304 raise RuntimeError("Test process did not start.") |
301 |
305 |
|
306 def startDebug(self, config, pythonpath, debugger): |
|
307 """ |
|
308 Public method to start the test run with debugger support. |
|
309 |
|
310 @param config configuration for the test execution |
|
311 @type TestConfig |
|
312 @param pythonpath list of directories to be added to the Python path |
|
313 @type list of str |
|
314 @param debugger refference to the debugger interface |
|
315 @type DebugUI |
|
316 """ |
|
317 workDir = ( |
|
318 config.discoveryStart |
|
319 if config.discover |
|
320 else os.path.dirname(config.testFilename) |
|
321 ) |
|
322 testArgs = self.createArguments(config) |
|
323 if pythonpath: |
|
324 currentPythonPath = os.environ.get("PYTHONPATH") |
|
325 newPythonPath = os.pathsep.join(pythonpath) |
|
326 if currentPythonPath: |
|
327 newPythonPath += os.pathsep + currentPythonPath |
|
328 environment = "PYTHONPATH={0}".format(newPythonPath) |
|
329 else: |
|
330 environment = "" |
|
331 |
|
332 self.__debugger = debugger |
|
333 self.__debugger.debuggingFinished.connect(self.finished) |
|
334 self.testRunAboutToBeStarted.emit() |
|
335 |
|
336 self.__debugger.debugInternalScript( |
|
337 venvName=config.venvName, |
|
338 scriptName=testArgs[0], |
|
339 argv=testArgs[1:], |
|
340 workDir=workDir, |
|
341 environment=environment, |
|
342 clientType=self._language, |
|
343 forProject=False, |
|
344 ) |
|
345 |
302 def finished(self): |
346 def finished(self): |
303 """ |
347 """ |
304 Public method handling the unit test process been finished. |
348 Public method handling the unit test process been finished. |
305 |
349 |
306 This method should read the results (if necessary) and emit the signal |
350 This method should read the results (if necessary) and emit the signal |
307 testFinished. |
351 testFinished. |
308 |
352 """ |
309 @exception NotImplementedError this method needs to be implemented by |
353 if self.__debugger is not None: |
310 derived classes |
354 self.__debugger.debuggingFinished.disconnect(self.finished) |
311 """ |
355 self.__debugger = None |
312 raise NotImplementedError |
|
313 |
356 |
314 def readAllOutput(self, process=None): |
357 def readAllOutput(self, process=None): |
315 """ |
358 """ |
316 Public method to read all output of the test process. |
359 Public method to read all output of the test process. |
317 |
360 |