--- a/src/eric7/Testing/Interfaces/UnittestExecutor.py Sun Dec 03 14:54:00 2023 +0100 +++ b/src/eric7/Testing/Interfaces/UnittestExecutor.py Mon Jan 01 11:10:45 2024 +0100 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2022 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> +# Copyright (c) 2022 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> # """ @@ -82,15 +82,19 @@ def hasCoverage(self, interpreter): # noqa: U100 """ - Public method to get the test framework version and version information - of its installed plugins. + Public method to check, if the collection of coverage data is available. @param interpreter interpreter to be used for the test @type str @return flag indicating the availability of coverage functionality @rtype bool """ - return True + proc = QProcess() + proc.start(interpreter, [UnittestExecutor.runner, "has_coverage"]) + if proc.waitForFinished(3000): + return proc.exitCode() == 0 + + return False def supportsPatterns(self, interpreter): # noqa: U100 """ @@ -115,7 +119,7 @@ """ args = [ UnittestExecutor.runner, - "runtest", + "discovery" if config.discoverOnly else "runtest", self.reader.address(), str(self.reader.port()), ] @@ -149,6 +153,8 @@ if config.testFilename: args.append(config.testFilename) args.extend(self.__testWidget.getFailedTests()) + elif config.testCases: + args.extend(config.testCases) elif config.testFilename: args.append(config.testFilename) args.append(config.testName if config.testName else "@NONE@") @@ -156,6 +162,20 @@ return args + def discover(self, config, pythonpath): + """ + Public method to start the test discovery process. + + @param config configuration for the test discovery + @type TestConfig + @param pythonpath list of directories to be added to the Python path + @type list of str + """ + self.reader = EricJsonReader(name="Unittest Reader", parent=self) + self.reader.dataReceived.connect(self.__processData) + + super().discover(config, pythonpath) + def start(self, config, pythonpath): """ Public method to start the testing process. @@ -170,6 +190,22 @@ super().start(config, pythonpath) + 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 + """ + self.reader = EricJsonReader(name="Unittest Reader", parent=self) + self.reader.dataReceived.connect(self.__processData) + + super().startDebug(config, pythonpath, debugger) + def finished(self): """ Public method handling the unit test process been finished. @@ -182,6 +218,8 @@ output = self.readAllOutput() self.testFinished.emit([], output) + super().finished() + @pyqtSlot(object) def __processData(self, data): """ @@ -197,7 +235,17 @@ # tests collected elif data["event"] == "collected": self.collected.emit( - [(t["id"], t["name"], t["description"]) for t in data["tests"]] + [ + ( + t["id"], + t["name"], + t["description"], + t["filename"], + 0, + t["id"].split("."), + ) + for t in data["tests"] + ] ) # test started