Compute code coverage correctly on platform-specific files, no-cover some trivial things, remove caching of .venv.#144
Conversation
| QtWidgets = importlib.import_module(QtModuleName + ".QtWidgets", package=QtModuleName) | ||
| QApplication = QtWidgets.QApplication | ||
|
|
||
| if QtModuleName == "PyQt5": | ||
| from PyQt5 import QtWidgets | ||
| if QtModuleName == "PyQt5": # pragma: no cover | ||
| from PyQt5.QtCore import pyqtSlot as Slot | ||
|
|
||
| QApplication = QtWidgets.QApplication | ||
|
|
||
| elif QtModuleName == "PyQt6": | ||
| from PyQt6 import QtWidgets | ||
| elif QtModuleName == "PyQt6": # pragma: no cover | ||
| from PyQt6.QtCore import pyqtSlot as Slot | ||
|
|
||
| QApplication = QtWidgets.QApplication | ||
|
|
||
| elif QtModuleName == "PySide2": | ||
| from PySide2 import QtWidgets | ||
| elif QtModuleName == "PySide2": # pragma: no cover | ||
| from PySide2.QtCore import Slot | ||
|
|
||
| QApplication = QtWidgets.QApplication | ||
|
|
||
| elif QtModuleName == "PySide6": | ||
| from PySide6 import QtWidgets | ||
| elif QtModuleName == "PySide6": # pragma: no cover | ||
| from PySide6.QtCore import Slot | ||
|
|
||
| QApplication = QtWidgets.QApplication | ||
|
|
There was a problem hiding this comment.
FWIW: I simplified the importing of QApplication in the process; importing Slot gets no-covered because there's really nothing we need to test here; adding PyQt5 etc conditionals would be a huge waste of time.
|
I also enabled printing missed branches so it's easier for us to know where to fill the gaps in. |
|
Slot import should be reduced to Slot = getattr(QtCore, "pyqtSlot", None) or getattr(QtCore, "Slot")ProcessEventFlags should be usable inline I think, without the need to if guard it. Although I recall it broke tests, so maybe using # run loop one last time to process all the events
self.__app.eventDispatcher().processEvents(
QtCore.QEventLoop.ProcessEventsFlags(0x00)
)QT_API env var does get used in the CI in all configurations, I see no reason to "no cover" it. I don't want to have comments explaining coverage and tests in the |
| try: | ||
| QtModuleName = env_to_mod_map[qtapi_env] | ||
| else: | ||
| except KeyError as e: # pragma: no cover |
There was a problem hiding this comment.
FWIW: I made this use try except for an extremely minor speed up — you don’t need to check for existness in the dict first when it exists — and from my experience it’s more pythonic to ask for forgiveness like this.
|
Too many conflicts, closings. |
See title.
Caching of .venv is removed because we frequently get incompatible architechtures -- the arch is not included in the caching and it does not save much time anyway since PyQt is always reinstalled.