DataViews/PyCoverageDialog.py

branch
Py2 comp.
changeset 2847
1843ef6e2656
parent 2525
8b507a9a2d40
parent 2826
22c39062c274
child 3057
10516539f238
equal deleted inserted replaced
2846:b852fe4d153a 2847:1843ef6e2656
13 13
14 from PyQt4.QtCore import pyqtSlot, Qt 14 from PyQt4.QtCore import pyqtSlot, Qt
15 from PyQt4.QtGui import QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, \ 15 from PyQt4.QtGui import QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, \
16 QApplication, QProgressDialog 16 QApplication, QProgressDialog
17 17
18 from E5Gui import E5MessageBox
18 from E5Gui.E5Application import e5App 19 from E5Gui.E5Application import e5App
19 20
20 from .Ui_PyCoverageDialog import Ui_PyCoverageDialog 21 from .Ui_PyCoverageDialog import Ui_PyCoverageDialog
21 22
22 import Utilities 23 import Utilities
23 from DebugClients.Python3.coverage import coverage 24 from DebugClients.Python3.coverage import coverage
25 from DebugClients.Python3.coverage.misc import CoverageException
24 26
25 27
26 class PyCoverageDialog(QDialog, Ui_PyCoverageDialog): 28 class PyCoverageDialog(QDialog, Ui_PyCoverageDialog):
27 """ 29 """
28 Class implementing a dialog to display the collected code coverage data. 30 Class implementing a dialog to display the collected code coverage data.
170 self.checkProgress.setMaximum(len(files)) 172 self.checkProgress.setMaximum(len(files))
171 QApplication.processEvents() 173 QApplication.processEvents()
172 174
173 total_statements = 0 175 total_statements = 0
174 total_executed = 0 176 total_executed = 0
177 total_exceptions = 0
175 178
176 cover.exclude(self.excludeList[0]) 179 cover.exclude(self.excludeList[0])
177 progress = 0 180 progress = 0
178 181
179 try: 182 try:
184 # now go through all the files 187 # now go through all the files
185 for file in files: 188 for file in files:
186 if self.cancelled: 189 if self.cancelled:
187 return 190 return
188 191
189 statements, excluded, missing, readable = cover.analysis2(file)[1:] 192 try:
190 readableEx = excluded and self.__format_lines(excluded) or '' 193 statements, excluded, missing, readable = cover.analysis2(file)[1:]
191 n = len(statements) 194 readableEx = excluded and self.__format_lines(excluded) or ''
192 m = n - len(missing) 195 n = len(statements)
193 if n > 0: 196 m = n - len(missing)
194 pc = 100.0 * m / n 197 if n > 0:
195 else: 198 pc = 100.0 * m / n
196 pc = 100.0 199 else:
197 self.__createResultItem(file, str(n), str(m), pc, readableEx, readable) 200 pc = 100.0
198 201 self.__createResultItem(
199 total_statements = total_statements + n 202 file, str(n), str(m), pc, readableEx, readable)
200 total_executed = total_executed + m 203
204 total_statements = total_statements + n
205 total_executed = total_executed + m
206 except CoverageException:
207 total_exceptions += 1
201 208
202 progress += 1 209 progress += 1
203 self.checkProgress.setValue(progress) 210 self.checkProgress.setValue(progress)
204 QApplication.processEvents() 211 QApplication.processEvents()
205 finally: 212 finally:
222 for col in range(0, 3): 229 for col in range(0, 3):
223 itm.setTextAlignment(col, Qt.AlignRight) 230 itm.setTextAlignment(col, Qt.AlignRight)
224 else: 231 else:
225 self.summaryGroup.hide() 232 self.summaryGroup.hide()
226 233
234 if total_exceptions:
235 E5MessageBox.warning(self,
236 self.trUtf8("Parse Error"),
237 self.trUtf8("""%n file(s) could not be parsed. Coverage info for"""
238 """ these is not available.""", "", total_exceptions))
239
227 self.__finish() 240 self.__finish()
228 241
229 def __finish(self): 242 def __finish(self):
230 """ 243 """
231 Private slot called when the action finished or the user pressed the button. 244 Private slot called when the action finished or the user pressed the button.

eric ide

mercurial