diff -r 7c6bd2366602 -r af9a6dac2611 src/eric7/Testing/Interfaces/TestExecutorBase.py --- a/src/eric7/Testing/Interfaces/TestExecutorBase.py Sat Dec 16 15:21:11 2023 +0100 +++ b/src/eric7/Testing/Interfaces/TestExecutorBase.py Sat Dec 16 16:30:55 2023 +0100 @@ -69,6 +69,7 @@ eraseCoverage: bool = False # erase coverage data first coverageFile: str = "" # name of the coverage data file discoverOnly: bool = False # test discovery only + venvName: str = "" # name of the virtual environment class TestExecutorBase(QObject): @@ -127,6 +128,9 @@ super().__init__(testWidget) self.__process = None + self.__debugger = None + + self._language = "Python3" @classmethod def isInstalled(cls, interpreter): @@ -299,17 +303,56 @@ if not running: raise RuntimeError("Test process did not start.") + def startDebug(self, config, pythonpath, debugger): + """ + Public method to start the test run with debugger support. + + @param config configuration for the test execution + @type TestConfig + @param pythonpath list of directories to be added to the Python path + @type list of str + @param debugger refference to the debugger interface + @type DebugUI + """ + workDir = ( + config.discoveryStart + if config.discover + else os.path.dirname(config.testFilename) + ) + testArgs = self.createArguments(config) + if pythonpath: + currentPythonPath = os.environ.get("PYTHONPATH") + newPythonPath = os.pathsep.join(pythonpath) + if currentPythonPath: + newPythonPath += os.pathsep + currentPythonPath + environment = "PYTHONPATH={0}".format(newPythonPath) + else: + environment = "" + + self.__debugger = debugger + self.__debugger.debuggingFinished.connect(self.finished) + self.testRunAboutToBeStarted.emit() + + self.__debugger.debugInternalScript( + venvName=config.venvName, + scriptName=testArgs[0], + argv=testArgs[1:], + workDir=workDir, + environment=environment, + clientType=self._language, + forProject=False, + ) + def finished(self): """ Public method handling the unit test process been finished. This method should read the results (if necessary) and emit the signal testFinished. - - @exception NotImplementedError this method needs to be implemented by - derived classes """ - raise NotImplementedError + if self.__debugger is not None: + self.__debugger.debuggingFinished.disconnect(self.finished) + self.__debugger = None def readAllOutput(self, process=None): """