eric7/Testing/Interfaces/UnittestExecutor.py

branch
unittest
changeset 9089
b48a6d0f6309
parent 9070
eab09a1ab8ce
child 9192
a763d57e23bc
--- a/eric7/Testing/Interfaces/UnittestExecutor.py	Fri May 20 11:31:18 2022 +0200
+++ b/eric7/Testing/Interfaces/UnittestExecutor.py	Mon May 23 16:48:19 2022 +0200
@@ -79,6 +79,18 @@
         
         return {}
     
+    def hasCoverage(self, interpreter):
+        """
+        Public method to get the test framework version and version information
+        of its installed plugins.
+        
+        @param interpreter interpreter to be used for the test
+        @type str
+        @return flag indicating the availability of coverage functionality
+        @rtype bool
+        """
+        return True
+    
     def createArguments(self, config):
         """
         Public method to create the arguments needed to start the test process.
@@ -118,10 +130,9 @@
             if config.testFilename:
                 args.append(config.testFilename)
             args.extend(self.__testWidget.getFailedTests())
-        
-        elif config.testFilename and config.testName:
+        elif config.testFilename:
             args.append(config.testFilename)
-            args.append(config.testName)
+            args.append(config.testName if config.testName else "suite")
         
         return args
     
@@ -178,10 +189,8 @@
         # test result
         elif data["event"] == "result":
             filename, lineno = None, None
-            tracebackLines = []
-            if "traceback" in data:
-                # get the error info
-                tracebackLines = data["traceback"].splitlines()
+            tracebackLines = data.get("traceback", "").splitlines()
+            if tracebackLines:
                 # find the last entry matching the pattern
                 for index in range(len(tracebackLines) - 1, -1, -1):
                     fmatch = re.search(r'File "(.*?)", line (\d*?),.*',
@@ -192,12 +201,9 @@
                     filename = fmatch.group(1)
                     lineno = int(fmatch.group(2))
                 
-            if "shortmsg" in data:
-                message = data["shortmsg"]
-            elif tracebackLines:
+            message = data.get("shortmsg", "")
+            if not message and tracebackLines:
                 message = tracebackLines[-1].split(":", 1)[1].strip()
-            else:
-                message = ""
             
             self.testResult.emit(TestResult(
                 category=self.__statusCategoryMapping[data["status"]],
@@ -207,12 +213,10 @@
                 description=data["description"],
                 message=message,
                 extra=tracebackLines,
-                duration=(
-                    data["duration_ms"] if "duration_ms" in data else None
-                ),
+                duration=data.get("duration_ms", None),
                 filename=filename,
                 lineno=lineno,
-                subtestResult=data["subtest"] if "subtest" in data else False
+                subtestResult=data.get("subtest", False)
             ))
         
         # test run finished

eric ide

mercurial