Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail when both PySide2 and PyQt5 are installed in the test env #196

Closed
jni opened this issue Mar 24, 2021 · 0 comments · Fixed by #210
Closed

Tests fail when both PySide2 and PyQt5 are installed in the test env #196

jni opened this issue Mar 24, 2021 · 0 comments · Fixed by #210
Labels
bug Something isn't working

Comments

@jni
Copy link
Contributor

jni commented Mar 24, 2021

Describe the bug

If I have both PySide2 and PyQt5 in the environment, I get the following test failure:

 $ pytest tests/test_magicgui.py::test_auto_call
=============================== test session starts ===============================
platform linux -- Python 3.8.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- /home/jni/miniconda3/envs/all/bin/python
cachedir: .pytest_cache
PySide2 5.14.2.1 -- Qt runtime 5.14.2 -- Qt compiled 5.14.2
rootdir: /home/jni/projects/magicgui, configfile: setup.cfg
plugins: mypy-plugins-1.6.1, napari-plugin-engine-0.1.9, timeout-1.3.4, httpserver-0.3.4, ordering-0.6, qt-3.3.0, cov-2.8.1, napari-0.4.4.dev89+ge33c2fd1
collected 1 item                                                                  

tests/test_magicgui.py::test_auto_call FAILED                               [100%]

==================================== FAILURES =====================================
_________________________________ test_auto_call __________________________________

qtbot = <pytestqt.qtbot.QtBot object at 0x7f0d8dce2940>
magic_func = <FunctionGui func(a: str = 'works', b: int = 6, c=7.1) -> str>

    def test_auto_call(qtbot, magic_func):
        """Test that changing a parameter calls the function."""
    
        # TODO: remove qtbot requirement so we can test other backends eventually.
    
        # changing the widget parameter calls the function
        with qtbot.waitSignal(magic_func.called, timeout=1000):
            magic_func.b.value = 6
    
        # changing the gui calls the function
        with qtbot.waitSignal(magic_func.called, timeout=1000):
>           qtbot.keyClick(magic_func.a.native, Qt.Key_A, Qt.ControlModifier)

tests/test_magicgui.py:131: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (<PyQt5.QtWidgets.QLineEdit object at 0x7f0d917079d0>, 65, 67108864)
kwargs = {}

    def result(*args, **kwargs):
>       return qtest_method(*args, **kwargs)
E       TypeError: 'PySide2.QtTest.QTest.keyClick' called with wrong argument types:
E         PySide2.QtTest.QTest.keyClick(QLineEdit, Key, KeyboardModifier)
E       Supported signatures:
E         PySide2.QtTest.QTest.keyClick(PySide2.QtWidgets.QWidget, PySide2.QtCore.Qt.Key, PySide2.QtCore.Qt.KeyboardModifiers = PySide2.QtCore.Qt.KeyboardModifier.NoModifier, int = -1)
E         PySide2.QtTest.QTest.keyClick(PySide2.QtWidgets.QWidget, typing.Char, PySide2.QtCore.Qt.KeyboardModifiers = PySide2.QtCore.Qt.KeyboardModifier.NoModifier, int = -1)
E         PySide2.QtTest.QTest.keyClick(PySide2.QtGui.QWindow, PySide2.QtCore.Qt.Key, PySide2.QtCore.Qt.KeyboardModifiers = PySide2.QtCore.Qt.KeyboardModifier.NoModifier, int = -1)
E         PySide2.QtTest.QTest.keyClick(PySide2.QtGui.QWindow, typing.Char, PySide2.QtCore.Qt.KeyboardModifiers = PySide2.QtCore.Qt.KeyboardModifier.NoModifier, int = -1)

../../miniconda3/envs/all/lib/python3.8/site-packages/pytestqt/qtbot.py:626: TypeError
============================= short test summary info =============================
FAILED tests/test_magicgui.py::test_auto_call - TypeError: 'PySide2.QtTest.QTest...
================================ 1 failed in 0.22s ================================

Using QT_API=PySide2 pytest tests/test_magicgui.py::test_auto_call resolves the problem, but QT_API=PyQt5 pytest tests/test_magicgui.py::test_auto_call does not. So it seems pytest-qtbot is choosing PySide2 and ignoring the QT_API variable.

Expected behavior
Failure could be "expected" and marked as xfail, or magicgui could match pytest-qtbot during testing.

Environment (please complete the following information):

  • OS: mac, Linux
  • backend: Both!
  • magicgui version 61d8f4f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant