src/eric7/Testing/Interfaces/UnittestExecutor.py

branch
eric7
changeset 10405
df7e1694d0eb
parent 10404
f7d9c31f0c38
child 10415
af9a6dac2611
diff -r f7d9c31f0c38 -r df7e1694d0eb src/eric7/Testing/Interfaces/UnittestExecutor.py
--- a/src/eric7/Testing/Interfaces/UnittestExecutor.py	Tue Dec 12 16:43:51 2023 +0100
+++ b/src/eric7/Testing/Interfaces/UnittestExecutor.py	Wed Dec 13 15:54:55 2023 +0100
@@ -115,7 +115,7 @@
         """
         args = [
             UnittestExecutor.runner,
-            "runtest",
+            "discovery" if config.discoverOnly else "runtest",
             self.reader.address(),
             str(self.reader.port()),
         ]
@@ -149,6 +149,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 +158,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.
@@ -197,7 +213,17 @@
         # tests collected
         elif data["event"] == "collected":
             self.collected.emit(
-                [(t["id"], t["name"], t["description"], "", 0) for t in data["tests"]]
+                [
+                    (
+                        t["id"],
+                        t["name"],
+                        t["description"],
+                        t["filename"],
+                        0,
+                        t["id"].split("."),
+                    )
+                    for t in data["tests"]
+                ]
             )
 
         # test started

eric ide

mercurial