I think there *is* a way to fix both this and #1124166 in pytest-qt.
In Debian, python3-pyqt{5,6} are single packages, but
python3-pyside{2,6}.qt* are sets of per-module packages. The
autodetection code
https://sources.debian.org/src/pytest-qt/4.4.0-3/src/pytestqt/qt_compat.py?hl=76#L64
considers $qtapi installed if $qtapi.QtCore exists, but pytest-qt then
imports $qtapi.QtTest
https://sources.debian.org/src/pytest-qt/4.4.0-3/src/pytestqt/qt_compat.py?hl=110#L102
(and also $qtapi.QtGui and $qtapi.QtWidgets, but python3-pyside*.qttest
already depends on those). Hence, if python3-pyside2.qtcore is
installed but python3-pyside2.qttest is not, pytest-qt with no API set
will crash: this is #1124166.
Hence, I propose:
- Patch _guess_qt_api to check for QtTest instead of QtCore.
- Revert to no pyside* dependencies in this package.
i.e. (untested)
--- a/debian/control
+++ b/debian/control
@@ -27,7 +27,7 @@ Rules-Requires-Root: no
Package: python3-pytestqt
Architecture: all
Depends: ${misc:Depends},
- ${python3:Depends}, python3-pyside2.qttest |
python3-pyside6.qttest
+ ${python3:Depends}
Recommends: python3-pyqt5 | python3-pyqt6 | python3-pyqt4
Suggests: python-pytestqt-doc <!nodoc>
Description: pytest plugin for Qt application testing (Python 3)
--- a/src/pytestqt/qt_compat.py
+++ b/src/pytestqt/qt_compat.py
@@ -73,7 +73,7 @@ class _QtApi:
# Note, not importing only the root namespace because when
uninstalling from conda,
# the namespace can still be there.
for api, backend in QT_APIS.items():
- if _can_import(f"{backend}.QtCore"):
+ if _can_import(f"{backend}.QtTest"):
return api
return None
(If you want to change the default preference order, also reorder
https://sources.debian.org/src/pytest-qt/4.4.0-3/src/pytestqt/qt_compat.py#L20
, but I don't think that's necessary.)
After this, if python3-pyside*.qtcore is installed (because some
dependency is using it) but python3-pyside*.qttest is not, then
pytest-qt will consider pyside not installed and use pyqt. This should
avoid #1124166 (qttest not found) while not creating any new instances
of #1125222 (this: a package that is only compatible with pyqt is tested
against pyside).
(It would remain possible that a package that wanted pyqt5 got pyqt6
because one of its dependencies used that, so packages that care about
Qt version still need to set PYTEST_QT_API / pytest.qt_api, but that was
already the case in pytest-qt 4.4.0-1.)