eric6/DebugClients/Python/DCTestResult.py

changeset 8543
29d7b90ede28
parent 7960
e8fc383322f7
diff -r db1794734aec -r 29d7b90ede28 eric6/DebugClients/Python/DCTestResult.py
--- a/eric6/DebugClients/Python/DCTestResult.py	Mon Aug 23 13:43:27 2021 +0200
+++ b/eric6/DebugClients/Python/DCTestResult.py	Wed Aug 25 17:33:29 2021 +0200
@@ -29,7 +29,7 @@
         TestResult.__init__(self)
         self.__dbgClient = dbgClient
         self.failfast = failfast
-        
+    
     def addFailure(self, test, err):
         """
         Public method called if a test failed.
@@ -44,7 +44,7 @@
             "traceback": tracebackLines,
             "id": test.id(),
         })
-        
+    
     def addError(self, test, err):
         """
         Public method called if a test errored.
@@ -59,7 +59,31 @@
             "traceback": tracebackLines,
             "id": test.id(),
         })
+    
+    def addSubTest(self, test, subtest, err):
+        """
+        Public method called for each subtest to record its result.
         
+        @param test reference to the test object
+        @param subtest reference to the subtest object
+        @param err error traceback
+        """
+        if err is not None:
+            TestResult.addSubTest(self, test, subtest, err)
+            tracebackLines = self._exc_info_to_string(err, test)
+            if issubclass(err[0], test.failureException):
+                self.__dbgClient.sendJsonCommand("ResponseUTTestFailed", {
+                    "testname": str(subtest),
+                    "traceback": tracebackLines,
+                    "id": test.id(),
+                })
+            else:
+                self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", {
+                    "testname": str(subtest),
+                    "traceback": tracebackLines,
+                    "id": test.id(),
+                })
+    
     def addSkip(self, test, reason):
         """
         Public method called if a test was skipped.
@@ -73,7 +97,7 @@
             "reason": reason,
             "id": test.id(),
         })
-        
+    
     def addExpectedFailure(self, test, err):
         """
         Public method called if a test failed expected.
@@ -88,7 +112,7 @@
             "traceback": tracebackLines,
             "id": test.id(),
         })
-        
+    
     def addUnexpectedSuccess(self, test):
         """
         Public method called if a test succeeded expectedly.
@@ -100,7 +124,7 @@
             "testname": str(test),
             "id": test.id(),
         })
-        
+    
     def startTest(self, test):
         """
         Public method called at the start of a test.
@@ -112,7 +136,7 @@
             "testname": str(test),
             "description": test.shortDescription(),
         })
-
+    
     def stopTest(self, test):
         """
         Public method called at the end of a test.

eric ide

mercurial