DebugClients/Python3/DCTestResult.py

branch
jsonrpc
changeset 5128
b6cbdba69967
parent 4631
5c1a96925da4
child 5129
e4ab234cf071
diff -r eb1b3e0577e4 -r b6cbdba69967 DebugClients/Python3/DCTestResult.py
--- a/DebugClients/Python3/DCTestResult.py	Thu Sep 01 20:03:50 2016 +0200
+++ b/DebugClients/Python3/DCTestResult.py	Fri Sep 02 19:14:41 2016 +0200
@@ -11,9 +11,9 @@
 from unittest import TestResult
 
 
-from DebugProtocol import ResponseUTTestFailed, ResponseUTTestErrored, \
-    ResponseUTStartTest, ResponseUTStopTest, ResponseUTTestSkipped, \
-    ResponseUTTestFailedExpected, ResponseUTTestSucceededUnexpected
+##from DebugProtocol import ResponseUTTestFailed, ResponseUTTestErrored, \
+##    ResponseUTStartTest, ResponseUTStopTest, ResponseUTTestSkipped, \
+##    ResponseUTTestFailedExpected, ResponseUTTestSucceededUnexpected
 
 
 class DCTestResult(TestResult):
@@ -22,14 +22,15 @@
     
     For more details see unittest.py of the standard python distribution.
     """
-    def __init__(self, parent):
+    def __init__(self, dbgClient):
         """
         Constructor
         
-        @param parent The parent widget.
+        @param dbgClient reference to the debug client
+        @type DebugClientBase
         """
         TestResult.__init__(self)
-        self.parent = parent
+        self.__dbgClient = dbgClient
         
     def addFailure(self, test, err):
         """
@@ -40,9 +41,14 @@
         """
         TestResult.addFailure(self, test, err)
         tracebackLines = self._exc_info_to_string(err, test)
-        self.parent.write('{0}{1}\n'.format(
-            ResponseUTTestFailed,
-            str((str(test), tracebackLines, test.id()))))
+##        self.parent.write('{0}{1}\n'.format(
+##            ResponseUTTestFailed,
+##            str((str(test), tracebackLines, test.id()))))
+        self.__dbgClient.sendJsonCommand("ResponseUTTestFailed", {
+            "testname": str(test),
+            "traceback": tracebackLines,
+            "id": test.id(),
+        })
         
     def addError(self, test, err):
         """
@@ -53,9 +59,14 @@
         """
         TestResult.addError(self, test, err)
         tracebackLines = self._exc_info_to_string(err, test)
-        self.parent.write('{0}{1}\n'.format(
-            ResponseUTTestErrored,
-            str((str(test), tracebackLines, test.id()))))
+##        self.parent.write('{0}{1}\n'.format(
+##            ResponseUTTestErrored,
+##            str((str(test), tracebackLines, test.id()))))
+        self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", {
+            "testname": str(test),
+            "traceback": tracebackLines,
+            "id": test.id(),
+        })
         
     def addSkip(self, test, reason):
         """
@@ -65,9 +76,14 @@
         @param reason reason for skipping the test (string)
         """
         TestResult.addSkip(self, test, reason)
-        self.parent.write('{0}{1}\n'.format(
-            ResponseUTTestSkipped,
-            str((str(test), reason, test.id()))))
+##        self.parent.write('{0}{1}\n'.format(
+##            ResponseUTTestSkipped,
+##            str((str(test), reason, test.id()))))
+        self.__dbgClient.sendJsonCommand("ResponseUTTestSkipped", {
+            "testname": str(test),
+            "reason": reason,
+            "id": test.id(),
+        })
         
     def addExpectedFailure(self, test, err):
         """
@@ -78,9 +94,14 @@
         """
         TestResult.addExpectedFailure(self, test, err)
         tracebackLines = self._exc_info_to_string(err, test)
-        self.parent.write('{0}{1}\n'.format(
-            ResponseUTTestFailedExpected,
-            str((str(test), tracebackLines, test.id()))))
+##        self.parent.write('{0}{1}\n'.format(
+##            ResponseUTTestFailedExpected,
+##            str((str(test), tracebackLines, test.id()))))
+        self.__dbgClient.sendJsonCommand("ResponseUTTestFailedExpected", {
+            "testname": str(test),
+            "traceback": tracebackLines,
+            "id": test.id(),
+        })
         
     def addUnexpectedSuccess(self, test):
         """
@@ -89,9 +110,13 @@
         @param test reference to the test object
         """
         TestResult.addUnexpectedSuccess(self, test)
-        self.parent.write('{0}{1}\n'.format(
-            ResponseUTTestSucceededUnexpected,
-            str((str(test), test.id()))))
+##        self.parent.write('{0}{1}\n'.format(
+##            ResponseUTTestSucceededUnexpected,
+##            str((str(test), test.id()))))
+        self.__dbgClient.sendJsonCommand("ResponseUTTestSucceededUnexpected", {
+            "testname": str(test),
+            "id": test.id(),
+        })
         
     def startTest(self, test):
         """
@@ -100,9 +125,13 @@
         @param test Reference to the test object
         """
         TestResult.startTest(self, test)
-        self.parent.write('{0}{1}\n'.format(
-            ResponseUTStartTest,
-            str((str(test), test.shortDescription()))))
+##        self.parent.write('{0}{1}\n'.format(
+##            ResponseUTStartTest,
+##            str((str(test), test.shortDescription()))))
+        self.__dbgClient.sendJsonCommand("ResponseUTStartTest", {
+            "testname": str(test),
+            "description": test.shortDescription(),
+        })
 
     def stopTest(self, test):
         """
@@ -111,14 +140,15 @@
         @param test Reference to the test object
         """
         TestResult.stopTest(self, test)
-        self.parent.write('{0}\n'.format(ResponseUTStopTest))
+##        self.parent.write('{0}\n'.format(ResponseUTStopTest))
+        self.__dbgClient.sendJsonCommand("ResponseUTStopTest", {})
         
         # ensure that pending input is processed
         rrdy, wrdy, xrdy = select.select(
-            [self.parent.readstream], [], [], 0.01)
+            [self.__dbgClient.readstream], [], [], 0.01)
 
-        if self.parent.readstream in rrdy:
-            self.parent.readReady(self.parent.readstream.fileno())
+        if self.__dbgClient.readstream in rrdy:
+            self.__dbgClient.readReady(self.__dbgClient.readstream.fileno())
 
 #
 # eflag: noqa = M702

eric ide

mercurial