Open svartkanin opened 2 years ago
I did configure the env variable QT_API for IPython QT_API=pyside
. However, at this stage https://github.com/pytest-dev/pytest-qt/blob/master/src/pytestqt/qt_compat.py#L64, pytest-qt is trying to import any possible qt library, which in this case will throw a nasty error from IPython since that one is not allowing any other imports than the ones defined. Currently only ModuleNotFoundError
is handled, but wouldn't it be possible to cater for others as well since there's a lot that might go wrong here?
def _can_import(name):
try:
_import(name)
return True
except ModuleNotFoundError as e:
self._import_errors[name] = str(e)
return False
As an alternative and very simple solution may I propose to just change the order in which the imports are being tried, to something like
if _can_import("PySide2.QtCore"):
return "pyside2"
elif _can_import("PyQt6.QtCore"):
return "pyqt6"
elif _can_import("PyQt5.QtCore"):
return "pyqt5"
elif _can_import("PySide6.QtCore"):
return "pyside6"
Hmm, right, apologies for closing this issue so quickly - reopening it for now.
@svartkanin One workaround is to use PYTEST_QT_API=pyside2
.
@eyllanesc got it right: this will prevent pytest-qt from trying to guess which API to use (the _guess_api
function).
When running any pytest I receive the following error
I suspect it has something to do with the Ipython package that is being used as well. Here is the full list of installed dependencies