eric7/Debugger/DebugServer.py

branch
unittest
changeset 9074
1afb90182258
parent 8881
54e42bc2437a
child 9088
b079ec4176db
equal deleted inserted replaced
9073:d88e53da6e66 9074:1afb90182258
99 connected in passive debug mode 99 connected in passive debug mode
100 @signal clientGone(bool) emitted if the client went away (planned or 100 @signal clientGone(bool) emitted if the client went away (planned or
101 unplanned) 101 unplanned)
102 @signal clientInterpreterChanged(str) emitted to signal a change of the 102 @signal clientInterpreterChanged(str) emitted to signal a change of the
103 client interpreter 103 client interpreter
104 @signal utDiscovered(testCases, exc_type, exc_value) emitted after the
105 client has performed a test case discovery action
106 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client
107 has loaded a unittest suite
108 @signal utFinished() emitted after the client signalled the end of the
109 unittest
110 @signal utStartTest(testname, testdocu) emitted after the client has
111 started a test
112 @signal utStopTest() emitted after the client has finished a test
113 @signal utTestFailed(testname, exc_info, id) emitted after the client
114 reported a failed test
115 @signal utTestErrored(testname, exc_info, id) emitted after the client
116 reported an errored test
117 @signal utTestSkipped(testname, reason, id) emitted after the client
118 reported a skipped test
119 @signal utTestFailedExpected(testname, exc_info, id) emitted after the
120 client reported an expected test failure
121 @signal utTestSucceededUnexpected(testname, id) emitted after the client
122 reported an unexpected test success
123 @signal callTraceInfo emitted after the client reported the call trace 104 @signal callTraceInfo emitted after the client reported the call trace
124 data (isCall, fromFile, fromLine, fromFunction, toFile, toLine, 105 data (isCall, fromFile, fromLine, fromFunction, toFile, toLine,
125 toFunction, debuggerId) 106 toFunction, debuggerId)
126 @signal appendStdout(msg) emitted when a passive debug connection is 107 @signal appendStdout(msg) emitted when a passive debug connection is
127 established or lost 108 established or lost
156 clientBanner = pyqtSignal(str, str, str) 137 clientBanner = pyqtSignal(str, str, str)
157 clientCapabilities = pyqtSignal(int, str, str) 138 clientCapabilities = pyqtSignal(int, str, str)
158 clientCompletionList = pyqtSignal(list, str) 139 clientCompletionList = pyqtSignal(list, str)
159 clientInterpreterChanged = pyqtSignal(str) 140 clientInterpreterChanged = pyqtSignal(str)
160 clientDebuggerId = pyqtSignal(str) 141 clientDebuggerId = pyqtSignal(str)
161 utDiscovered = pyqtSignal(list, str, str)
162 utPrepared = pyqtSignal(int, str, str)
163 utStartTest = pyqtSignal(str, str)
164 utStopTest = pyqtSignal()
165 utTestFailed = pyqtSignal(str, str, str)
166 utTestErrored = pyqtSignal(str, str, str)
167 utTestSkipped = pyqtSignal(str, str, str)
168 utTestFailedExpected = pyqtSignal(str, str, str)
169 utTestSucceededUnexpected = pyqtSignal(str, str)
170 utFinished = pyqtSignal()
171 passiveDebugStarted = pyqtSignal(str, bool) 142 passiveDebugStarted = pyqtSignal(str, bool)
172 callTraceInfo = pyqtSignal(bool, str, str, str, str, str, str, str) 143 callTraceInfo = pyqtSignal(bool, str, str, str, str, str, str, str)
173 appendStdout = pyqtSignal(str) 144 appendStdout = pyqtSignal(str)
174 145
175 def __init__(self, originalPathString, preventPassiveDebugging=False, 146 def __init__(self, originalPathString, preventPassiveDebugging=False,
1537 @param text the text to be completed 1508 @param text the text to be completed
1538 @type str 1509 @type str
1539 """ 1510 """
1540 self.debuggerInterface.remoteCompletion(debuggerId, text) 1511 self.debuggerInterface.remoteCompletion(debuggerId, text)
1541 1512
1542 def remoteUTDiscover(self, clientType, forProject, venvName, syspath,
1543 workdir, discoveryStart):
1544 """
1545 Public method to perform a test case discovery.
1546
1547 @param clientType client type to be used
1548 @type str
1549 @param forProject flag indicating a project related action
1550 @type bool
1551 @param venvName name of a virtual environment
1552 @type str
1553 @param syspath list of directories to be added to sys.path on the
1554 remote side
1555 @type list of str
1556 @param workdir path name of the working directory
1557 @type str
1558 @param discoveryStart directory to start auto-discovery at
1559 @type str
1560 """
1561 if clientType and clientType not in self.getSupportedLanguages():
1562 # a not supported client language was requested
1563 EricMessageBox.critical(
1564 None,
1565 self.tr("Start Debugger"),
1566 self.tr(
1567 """<p>The debugger type <b>{0}</b> is not supported"""
1568 """ or not configured.</p>""").format(clientType)
1569 )
1570 return
1571
1572 # Restart the client if there is already a program loaded.
1573 try:
1574 if clientType:
1575 self.__setClientType(clientType)
1576 except KeyError:
1577 self.__setClientType('Python3') # assume it is a Python3 file
1578 self.startClient(False, forProject=forProject, venvName=venvName)
1579
1580 self.debuggerInterface.remoteUTDiscover(
1581 syspath, workdir, discoveryStart)
1582
1583 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase,
1584 clientType="", forProject=False, venvName="",
1585 syspath=None, workdir="", discover=False,
1586 discoveryStart="", testCases=None, debug=False):
1587 """
1588 Public method to prepare a new unittest run.
1589
1590 @param fn the filename to load
1591 @type str
1592 @param tn the testname to load
1593 @type str
1594 @param tfn the test function name to load tests from
1595 @type str
1596 @param failed list of failed test, if only failed test should be run
1597 @type list of str
1598 @param cov flag indicating collection of coverage data is requested
1599 @type bool
1600 @param covname filename to be used to assemble the coverage caches
1601 filename
1602 @type str
1603 @param coverase flag indicating erasure of coverage data is requested
1604 @type bool
1605 @param clientType client type to be used
1606 @type str
1607 @param forProject flag indicating a project related action
1608 @type bool
1609 @param venvName name of a virtual environment
1610 @type str
1611 @param syspath list of directories to be added to sys.path on the
1612 remote side
1613 @type list of str
1614 @param workdir path name of the working directory
1615 @type str
1616 @param discover flag indicating to discover the tests automatically
1617 @type bool
1618 @param discoveryStart directory to start auto-discovery at
1619 @type str
1620 @param testCases list of test cases to be loaded
1621 @type list of str
1622 @param debug flag indicating to run unittest with debugging
1623 @type bool
1624 """
1625 if clientType and clientType not in self.getSupportedLanguages():
1626 # a not supported client language was requested
1627 EricMessageBox.critical(
1628 None,
1629 self.tr("Start Debugger"),
1630 self.tr(
1631 """<p>The debugger type <b>{0}</b> is not supported"""
1632 """ or not configured.</p>""").format(clientType)
1633 )
1634 return
1635
1636 # Restart the client if there is already a program loaded.
1637 try:
1638 if clientType:
1639 self.__setClientType(clientType)
1640 else:
1641 self.__setClientType(
1642 self.__findLanguageForExtension(os.path.splitext(fn)[1]))
1643 except KeyError:
1644 self.__setClientType('Python3') # assume it is a Python3 file
1645 self.startClient(False, forProject=forProject, venvName=venvName)
1646
1647 self.debuggerInterface.remoteUTPrepare(
1648 fn, tn, tfn, failed, cov, covname, coverase, syspath, workdir,
1649 discover, discoveryStart, testCases, debug)
1650 self.running = True
1651 self.debugging = debug
1652 if debug:
1653 self.__restoreBreakpoints()
1654 self.__restoreWatchpoints()
1655
1656 def remoteUTRun(self, debug=False, failfast=False):
1657 """
1658 Public method to start a unittest run.
1659
1660 @param debug flag indicating to run unittest with debugging
1661 @type bool
1662 @param failfast flag indicating to stop at the first error
1663 @type bool
1664 """
1665 self.debuggerInterface.remoteUTRun(debug, failfast)
1666
1667 def remoteUTStop(self):
1668 """
1669 public method to stop a unittest run.
1670 """
1671 self.debuggerInterface.remoteUTStop()
1672
1673 def signalClientOutput(self, line, debuggerId): 1513 def signalClientOutput(self, line, debuggerId):
1674 """ 1514 """
1675 Public method to process a line of client output. 1515 Public method to process a line of client output.
1676 1516
1677 @param line client output 1517 @param line client output
2034 """ 1874 """
2035 self.callTraceInfo.emit( 1875 self.callTraceInfo.emit(
2036 isCall, fromFile, fromLine, fromFunction, 1876 isCall, fromFile, fromLine, fromFunction,
2037 toFile, toLine, toFunction, debuggerId) 1877 toFile, toLine, toFunction, debuggerId)
2038 1878
2039 def clientUtDiscovered(self, testCases, exceptionType, exceptionValue):
2040 """
2041 Public method to process the client unittest discover info.
2042
2043 @param testCases list of detected test cases
2044 @type str
2045 @param exceptionType exception type
2046 @type str
2047 @param exceptionValue exception message
2048 @type str
2049 """
2050 self.utDiscovered.emit(testCases, exceptionType, exceptionValue)
2051
2052 def clientUtPrepared(self, result, exceptionType, exceptionValue):
2053 """
2054 Public method to process the client unittest prepared info.
2055
2056 @param result number of test cases (0 = error)
2057 @type int
2058 @param exceptionType exception type
2059 @type str
2060 @param exceptionValue exception message
2061 @type str
2062 """
2063 self.utPrepared.emit(result, exceptionType, exceptionValue)
2064
2065 def clientUtStartTest(self, testname, doc):
2066 """
2067 Public method to process the client start test info.
2068
2069 @param testname name of the test
2070 @type str
2071 @param doc short description of the test
2072 @type str
2073 """
2074 self.utStartTest.emit(testname, doc)
2075
2076 def clientUtStopTest(self):
2077 """
2078 Public method to process the client stop test info.
2079 """
2080 self.utStopTest.emit()
2081
2082 def clientUtTestFailed(self, testname, traceback, testId):
2083 """
2084 Public method to process the client test failed info.
2085
2086 @param testname name of the test
2087 @type str
2088 @param traceback lines of traceback info
2089 @type list of str
2090 @param testId id of the test
2091 @type str
2092 """
2093 self.utTestFailed.emit(testname, traceback, testId)
2094
2095 def clientUtTestErrored(self, testname, traceback, testId):
2096 """
2097 Public method to process the client test errored info.
2098
2099 @param testname name of the test
2100 @type str
2101 @param traceback lines of traceback info
2102 @type list of str
2103 @param testId id of the test
2104 @type str
2105 """
2106 self.utTestErrored.emit(testname, traceback, testId)
2107
2108 def clientUtTestSkipped(self, testname, reason, testId):
2109 """
2110 Public method to process the client test skipped info.
2111
2112 @param testname name of the test
2113 @type str
2114 @param reason reason for skipping the test
2115 @type str
2116 @param testId id of the test
2117 @type str
2118 """
2119 self.utTestSkipped.emit(testname, reason, testId)
2120
2121 def clientUtTestFailedExpected(self, testname, traceback, testId):
2122 """
2123 Public method to process the client test failed expected info.
2124
2125 @param testname name of the test
2126 @type str
2127 @param traceback lines of traceback info
2128 @type list of str
2129 @param testId id of the test
2130 @type str
2131 """
2132 self.utTestFailedExpected.emit(testname, traceback, testId)
2133
2134 def clientUtTestSucceededUnexpected(self, testname, testId):
2135 """
2136 Public method to process the client test succeeded unexpected info.
2137
2138 @param testname name of the test
2139 @type str
2140 @param testId id of the test
2141 @type str
2142 """
2143 self.utTestSucceededUnexpected.emit(testname, testId)
2144
2145 def clientUtFinished(self, status):
2146 """
2147 Public method to process the client unit test finished info.
2148
2149 @param status exit status of the unit test
2150 @type int
2151 """
2152 self.utFinished.emit()
2153
2154 self.clientExit.emit("", int(status), "", True, "")
2155 self.debugging = False
2156 self.running = False
2157
2158 def passiveStartUp(self, fn, exc, debuggerId): 1879 def passiveStartUp(self, fn, exc, debuggerId):
2159 """ 1880 """
2160 Public method to handle a passive debug connection. 1881 Public method to handle a passive debug connection.
2161 1882
2162 @param fn filename of the debugged script 1883 @param fn filename of the debugged script

eric ide

mercurial