5 |
5 |
6 """ |
6 """ |
7 Module implementing a Python code coverage dialog. |
7 Module implementing a Python code coverage dialog. |
8 """ |
8 """ |
9 |
9 |
|
10 import contextlib |
10 import os |
11 import os |
11 import contextlib |
12 import time |
12 |
13 |
13 from PyQt6.QtCore import pyqtSlot, Qt |
14 from PyQt6.QtCore import pyqtSlot, Qt |
14 from PyQt6.QtWidgets import ( |
15 from PyQt6.QtWidgets import ( |
15 QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, |
16 QDialog, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, |
16 QApplication |
17 QApplication |
192 # disable updates of the list for speed |
193 # disable updates of the list for speed |
193 self.resultList.setUpdatesEnabled(False) |
194 self.resultList.setUpdatesEnabled(False) |
194 self.resultList.setSortingEnabled(False) |
195 self.resultList.setSortingEnabled(False) |
195 |
196 |
196 # now go through all the files |
197 # now go through all the files |
|
198 now = time.monotonic() |
197 for progress, file in enumerate(files, start=1): |
199 for progress, file in enumerate(files, start=1): |
198 if self.cancelled: |
200 if self.cancelled: |
199 return |
201 return |
200 |
202 |
201 try: |
203 try: |
213 total_executed += m |
215 total_executed += m |
214 except CoverageException: |
216 except CoverageException: |
215 total_exceptions += 1 |
217 total_exceptions += 1 |
216 |
218 |
217 self.checkProgress.setValue(progress) |
219 self.checkProgress.setValue(progress) |
218 QApplication.processEvents() |
220 if time.monotonic() - now > 0.01: |
|
221 QApplication.processEvents() |
|
222 now = time.monotonic() |
219 finally: |
223 finally: |
220 # reenable updates of the list |
224 # reenable updates of the list |
221 self.resultList.setSortingEnabled(True) |
225 self.resultList.setSortingEnabled(True) |
222 self.resultList.setUpdatesEnabled(True) |
226 self.resultList.setUpdatesEnabled(True) |
223 self.checkProgress.reset() |
227 self.checkProgress.reset() |