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

Fix tests when both pyside2 and pyqt5 are installed #210

Merged
merged 1 commit into from
Apr 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions tests/test_magicgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@ def func(a: str = "works", b: int = 3, c=7.1) -> str:
@pytest.fixture
def magic_func():
"""Test function decorated by magicgui."""
decorated = magicgui(func, call_button="my_button", auto_call=True, labels=False)
return decorated
return magicgui(func, call_button="my_button", auto_call=True, labels=False)


@pytest.fixture
def magic_func_defaults():
decorated = magicgui(func)
return decorated
return magicgui(func)


@pytest.fixture
def magic_func_autocall():
decorated = magicgui(func, auto_call=True)
return decorated
return magicgui(func, auto_call=True)


def test_magicgui(magic_func):
Expand Down Expand Up @@ -141,17 +138,17 @@ def func(a: int, b: int = 3, c=7.1):

def test_auto_call(qtbot, magic_func):
"""Test that changing a parameter calls the function."""
from qtpy.QtTest import QTest

# 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)
qtbot.keyClick(magic_func.a.native, Qt.Key_Delete)
QTest.keyClick(magic_func.a.native, Qt.Key_A, Qt.ControlModifier)
QTest.keyClick(magic_func.a.native, Qt.Key_Delete)


def test_dropdown_list_from_enum():
Expand Down