pytest-dev / pytest-qt

pytest plugin for Qt (PyQt5/PyQt6 and PySide2/PySide6) application testing
https://pytest-qt.readthedocs.io
MIT License
409 stars 70 forks source link

PyQt6 support breaks PyQt5 on Ubuntu #369

Closed machinekoder closed 3 years ago

machinekoder commented 3 years ago

I'm currently facing an issue in my CI which looks related to a recent change in pytest-qt:

The culprit is this line here: https://github.com/pytest-dev/pytest-qt/blob/master/src/pytestqt/qt_compat.py#L144 which was introduced 3 months ago.

System: Ubuntu Focal Qt version: 5.12.8 PyQt5 version: 5.14.1

log:

INTERNALERROR> Traceback (most recent call last):
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/lib/python3/dist-packages/_pytest/main.py", line 202, in wrap_session
18:14:56

18:14:56
  INTERNALERROR>     config._do_configure()
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 723, in _do_configure
18:14:56

18:14:56
  INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 308, in call_historic
18:14:56

18:14:56
  INTERNALERROR>     res = self._hookexec(self, self.get_hookimpls(), kwargs)
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92, in _hookexec
18:14:56

18:14:56
  INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83, in <lambda>
18:14:56

18:14:56
  INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 208, in _multicall
18:14:56

18:14:56
  INTERNALERROR>     return outcome.get_result()
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 80, in get_result
18:14:56

18:14:56
  INTERNALERROR>     raise ex[1].with_traceback(ex[2])
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187, in _multicall
18:14:56

18:14:56
  INTERNALERROR>     res = hook_impl.function(*args)
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/local/lib/python3.8/dist-packages/pytestqt/plugin.py", line 203, in pytest_configure
18:14:56

18:14:56
  INTERNALERROR>     qt_api.set_qt_api(config.getini("qt_api"))
18:14:56
 INTERNALERROR>   File "/usr/local/lib/python3.8/dist-packages/pytestqt/qt_compat.py", line 144, in set_qt_api
18:14:56

18:14:56
  INTERNALERROR>     self.isdeleted = _import_module("sip").isdeleted
18:14:56

18:14:56
  INTERNALERROR>   File "/usr/local/lib/python3.8/dist-packages/pytestqt/qt_compat.py", line 101, in _import_module
18:14:56

18:14:56
  INTERNALERROR>     return getattr(m, module_name)
18:14:56

18:14:56
  INTERNALERROR> AttributeError: module 'PyQt5' has no attribute 'sip'
18:14:56

18:14:56
  [Testcase: testtest_lib] ... FAILURE!
18:14:56
nicoddemus commented 3 years ago

Hi @machinekoder,

Can you try this in your environment please?

>>> import PyQt5.sip
>>>
The-Compiler commented 3 years ago

Right, either Ubuntu or Debian seems to patch PyQt in a way which is incompatible with how upstream (and almost any other distribution) do things. See https://github.com/qutebrowser/qutebrowser/issues/6082 and https://github.com/qutebrowser/qutebrowser/commit/41087d3adf42c48ef08f5851af43b26809753c4c.

I suppose we can work around this in pytest-qt as well, but I'd also like to find out if this is due to Debian or Ubuntu, and then report it there.

reneeotten commented 3 years ago

I am seeing the same issue when packaging the update for MacPorts

The-Compiler commented 3 years ago

Could someone test #370 please, ideally both with PyQt5 and PyQt6?

reneeotten commented 3 years ago

Could someone test #370 please, ideally both with PyQt5 and PyQt6?

thanks @The-Compiler - works for me with PyQt5. Sorry, MacPorts hasn't ported PyQt6 yet so I didn't test it with that...

machinekoder commented 3 years ago

Hi @machinekoder,

Can you try this in your environment please?

>>> import PyQt5.sip
>>>
Python 3.8.5 (default, May 27 2021, 13:30:53) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5.sip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
The-Compiler commented 3 years ago

4.0.1 with the fix is out now. Thanks @machinekoder @reneeotten for the report and testing!