DebugClients/Python3/DCTestResult.py

branch
jsonrpc
changeset 5129
e4ab234cf071
parent 5128
b6cbdba69967
child 5131
889ed5ff7a68
equal deleted inserted replaced
5128:b6cbdba69967 5129:e4ab234cf071
7 Module implementing a TestResult derivative for the eric6 debugger. 7 Module implementing a TestResult derivative for the eric6 debugger.
8 """ 8 """
9 9
10 import select 10 import select
11 from unittest import TestResult 11 from unittest import TestResult
12
13
14 ##from DebugProtocol import ResponseUTTestFailed, ResponseUTTestErrored, \
15 ## ResponseUTStartTest, ResponseUTStopTest, ResponseUTTestSkipped, \
16 ## ResponseUTTestFailedExpected, ResponseUTTestSucceededUnexpected
17 12
18 13
19 class DCTestResult(TestResult): 14 class DCTestResult(TestResult):
20 """ 15 """
21 A TestResult derivative to work with eric6's debug client. 16 A TestResult derivative to work with eric6's debug client.
39 @param test Reference to the test object 34 @param test Reference to the test object
40 @param err The error traceback 35 @param err The error traceback
41 """ 36 """
42 TestResult.addFailure(self, test, err) 37 TestResult.addFailure(self, test, err)
43 tracebackLines = self._exc_info_to_string(err, test) 38 tracebackLines = self._exc_info_to_string(err, test)
44 ## self.parent.write('{0}{1}\n'.format(
45 ## ResponseUTTestFailed,
46 ## str((str(test), tracebackLines, test.id()))))
47 self.__dbgClient.sendJsonCommand("ResponseUTTestFailed", { 39 self.__dbgClient.sendJsonCommand("ResponseUTTestFailed", {
48 "testname": str(test), 40 "testname": str(test),
49 "traceback": tracebackLines, 41 "traceback": tracebackLines,
50 "id": test.id(), 42 "id": test.id(),
51 }) 43 })
57 @param test Reference to the test object 49 @param test Reference to the test object
58 @param err The error traceback 50 @param err The error traceback
59 """ 51 """
60 TestResult.addError(self, test, err) 52 TestResult.addError(self, test, err)
61 tracebackLines = self._exc_info_to_string(err, test) 53 tracebackLines = self._exc_info_to_string(err, test)
62 ## self.parent.write('{0}{1}\n'.format(
63 ## ResponseUTTestErrored,
64 ## str((str(test), tracebackLines, test.id()))))
65 self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", { 54 self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", {
66 "testname": str(test), 55 "testname": str(test),
67 "traceback": tracebackLines, 56 "traceback": tracebackLines,
68 "id": test.id(), 57 "id": test.id(),
69 }) 58 })
74 63
75 @param test reference to the test object 64 @param test reference to the test object
76 @param reason reason for skipping the test (string) 65 @param reason reason for skipping the test (string)
77 """ 66 """
78 TestResult.addSkip(self, test, reason) 67 TestResult.addSkip(self, test, reason)
79 ## self.parent.write('{0}{1}\n'.format(
80 ## ResponseUTTestSkipped,
81 ## str((str(test), reason, test.id()))))
82 self.__dbgClient.sendJsonCommand("ResponseUTTestSkipped", { 68 self.__dbgClient.sendJsonCommand("ResponseUTTestSkipped", {
83 "testname": str(test), 69 "testname": str(test),
84 "reason": reason, 70 "reason": reason,
85 "id": test.id(), 71 "id": test.id(),
86 }) 72 })
92 @param test reference to the test object 78 @param test reference to the test object
93 @param err error traceback 79 @param err error traceback
94 """ 80 """
95 TestResult.addExpectedFailure(self, test, err) 81 TestResult.addExpectedFailure(self, test, err)
96 tracebackLines = self._exc_info_to_string(err, test) 82 tracebackLines = self._exc_info_to_string(err, test)
97 ## self.parent.write('{0}{1}\n'.format(
98 ## ResponseUTTestFailedExpected,
99 ## str((str(test), tracebackLines, test.id()))))
100 self.__dbgClient.sendJsonCommand("ResponseUTTestFailedExpected", { 83 self.__dbgClient.sendJsonCommand("ResponseUTTestFailedExpected", {
101 "testname": str(test), 84 "testname": str(test),
102 "traceback": tracebackLines, 85 "traceback": tracebackLines,
103 "id": test.id(), 86 "id": test.id(),
104 }) 87 })
108 Public method called if a test succeeded expectedly. 91 Public method called if a test succeeded expectedly.
109 92
110 @param test reference to the test object 93 @param test reference to the test object
111 """ 94 """
112 TestResult.addUnexpectedSuccess(self, test) 95 TestResult.addUnexpectedSuccess(self, test)
113 ## self.parent.write('{0}{1}\n'.format(
114 ## ResponseUTTestSucceededUnexpected,
115 ## str((str(test), test.id()))))
116 self.__dbgClient.sendJsonCommand("ResponseUTTestSucceededUnexpected", { 96 self.__dbgClient.sendJsonCommand("ResponseUTTestSucceededUnexpected", {
117 "testname": str(test), 97 "testname": str(test),
118 "id": test.id(), 98 "id": test.id(),
119 }) 99 })
120 100
123 Public method called at the start of a test. 103 Public method called at the start of a test.
124 104
125 @param test Reference to the test object 105 @param test Reference to the test object
126 """ 106 """
127 TestResult.startTest(self, test) 107 TestResult.startTest(self, test)
128 ## self.parent.write('{0}{1}\n'.format(
129 ## ResponseUTStartTest,
130 ## str((str(test), test.shortDescription()))))
131 self.__dbgClient.sendJsonCommand("ResponseUTStartTest", { 108 self.__dbgClient.sendJsonCommand("ResponseUTStartTest", {
132 "testname": str(test), 109 "testname": str(test),
133 "description": test.shortDescription(), 110 "description": test.shortDescription(),
134 }) 111 })
135 112
138 Public method called at the end of a test. 115 Public method called at the end of a test.
139 116
140 @param test Reference to the test object 117 @param test Reference to the test object
141 """ 118 """
142 TestResult.stopTest(self, test) 119 TestResult.stopTest(self, test)
143 ## self.parent.write('{0}\n'.format(ResponseUTStopTest))
144 self.__dbgClient.sendJsonCommand("ResponseUTStopTest", {}) 120 self.__dbgClient.sendJsonCommand("ResponseUTStopTest", {})
145 121
146 # ensure that pending input is processed 122 # ensure that pending input is processed
147 rrdy, wrdy, xrdy = select.select( 123 rrdy, wrdy, xrdy = select.select(
148 [self.__dbgClient.readstream], [], [], 0.01) 124 [self.__dbgClient.readstream], [], [], 0.01)

eric ide

mercurial