DebugClients/Python/DCTestResult.py

changeset 0
de9c2efb9d02
child 13
1af94a91f439
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a TestResult derivative for the eric4 debugger.
8 """
9
10 import select
11 import traceback
12 from unittest import TestResult
13
14
15 from DebugProtocol import *
16
17
18 class DCTestResult(TestResult):
19 """
20 A TestResult derivative to work with eric4's debug client.
21
22 For more details see unittest.py of the standard python distribution.
23 """
24 def __init__(self, parent):
25 """
26 Constructor
27
28 @param parent The parent widget.
29 """
30 TestResult.__init__(self)
31 self.parent = parent
32
33 def addFailure(self, test, err):
34 """
35 Method called if a test failed.
36
37 @param test Reference to the test object
38 @param err The error traceback
39 """
40 TestResult.addFailure(self, test, err)
41 tracebackLines = traceback.format_exception(*(err + (10,)))
42 self.parent.write('%s%s\n' % (ResponseUTTestFailed,
43 unicode((unicode(test), tracebackLines))))
44
45 def addError(self, test, err):
46 """
47 Method called if a test errored.
48
49 @param test Reference to the test object
50 @param err The error traceback
51 """
52 TestResult.addError(self, test, err)
53 tracebackLines = traceback.format_exception(*(err + (10,)))
54 self.parent.write('%s%s\n' % (ResponseUTTestErrored,
55 unicode((unicode(test), tracebackLines))))
56
57 def startTest(self, test):
58 """
59 Method called at the start of a test.
60
61 @param test Reference to the test object
62 """
63 TestResult.startTest(self, test)
64 self.parent.write('%s%s\n' % (ResponseUTStartTest,
65 unicode((unicode(test), test.shortDescription()))))
66
67 def stopTest(self, test):
68 """
69 Method called at the end of a test.
70
71 @param test Reference to the test object
72 """
73 TestResult.stopTest(self, test)
74 self.parent.write('%s\n' % ResponseUTStopTest)
75
76 # ensure that pending input is processed
77 rrdy, wrdy, xrdy = select.select([self.parent.readstream],[],[], 0.01)
78
79 if self.parent.readstream in rrdy:
80 self.parent.readReady(self.parent.readstream.fileno())

eric ide

mercurial