11 |
11 |
12 from PyQt4.QtCore import pyqtSlot, Qt |
12 from PyQt4.QtCore import pyqtSlot, Qt |
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, \ |
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, \ |
14 QApplication, QProgressDialog |
14 QApplication, QProgressDialog |
15 |
15 |
|
16 from E5Gui import E5MessageBox |
16 from E5Gui.E5Application import e5App |
17 from E5Gui.E5Application import e5App |
17 |
18 |
18 from .Ui_PyCoverageDialog import Ui_PyCoverageDialog |
19 from .Ui_PyCoverageDialog import Ui_PyCoverageDialog |
19 |
20 |
20 import Utilities |
21 import Utilities |
21 from DebugClients.Python3.coverage import coverage |
22 from DebugClients.Python3.coverage import coverage |
|
23 from DebugClients.Python3.coverage.misc import CoverageException |
22 |
24 |
23 |
25 |
24 class PyCoverageDialog(QDialog, Ui_PyCoverageDialog): |
26 class PyCoverageDialog(QDialog, Ui_PyCoverageDialog): |
25 """ |
27 """ |
26 Class implementing a dialog to display the collected code coverage data. |
28 Class implementing a dialog to display the collected code coverage data. |
182 # now go through all the files |
185 # now go through all the files |
183 for file in files: |
186 for file in files: |
184 if self.cancelled: |
187 if self.cancelled: |
185 return |
188 return |
186 |
189 |
187 statements, excluded, missing, readable = cover.analysis2(file)[1:] |
190 try: |
188 readableEx = excluded and self.__format_lines(excluded) or '' |
191 statements, excluded, missing, readable = cover.analysis2(file)[1:] |
189 n = len(statements) |
192 readableEx = excluded and self.__format_lines(excluded) or '' |
190 m = n - len(missing) |
193 n = len(statements) |
191 if n > 0: |
194 m = n - len(missing) |
192 pc = 100.0 * m / n |
195 if n > 0: |
193 else: |
196 pc = 100.0 * m / n |
194 pc = 100.0 |
197 else: |
195 self.__createResultItem(file, str(n), str(m), pc, readableEx, readable) |
198 pc = 100.0 |
196 |
199 self.__createResultItem( |
197 total_statements = total_statements + n |
200 file, str(n), str(m), pc, readableEx, readable) |
198 total_executed = total_executed + m |
201 |
|
202 total_statements = total_statements + n |
|
203 total_executed = total_executed + m |
|
204 except CoverageException: |
|
205 total_exceptions += 1 |
199 |
206 |
200 progress += 1 |
207 progress += 1 |
201 self.checkProgress.setValue(progress) |
208 self.checkProgress.setValue(progress) |
202 QApplication.processEvents() |
209 QApplication.processEvents() |
203 finally: |
210 finally: |
220 for col in range(0, 3): |
227 for col in range(0, 3): |
221 itm.setTextAlignment(col, Qt.AlignRight) |
228 itm.setTextAlignment(col, Qt.AlignRight) |
222 else: |
229 else: |
223 self.summaryGroup.hide() |
230 self.summaryGroup.hide() |
224 |
231 |
|
232 if total_exceptions: |
|
233 E5MessageBox.warning(self, |
|
234 self.trUtf8("Parse Error"), |
|
235 self.trUtf8("""%n file(s) could not be parsed. Coverage info for""" |
|
236 """ these is not available.""", "", total_exceptions)) |
|
237 |
225 self.__finish() |
238 self.__finish() |
226 |
239 |
227 def __finish(self): |
240 def __finish(self): |
228 """ |
241 """ |
229 Private slot called when the action finished or the user pressed the button. |
242 Private slot called when the action finished or the user pressed the button. |