Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
python-version: [3.6, 3.7, 3.8]
qt-lib: [pyqt5, pyside2]
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- python-version: "3.6"
tox-env: "py36"
Expand Down
43 changes: 6 additions & 37 deletions tests/test_wait_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
CallbackCalledTwiceError,
)

flaky_on_macos = pytest.mark.xfail(
sys.platform == "darwin", run=False, reason="Flaky on macOS: #313"
)


def test_signal_blocker_exception(qtbot):
"""
Expand Down Expand Up @@ -81,6 +85,7 @@ def build_signal_tests_variants(params):
]
),
)
@flaky_on_macos
def test_signal_triggered(
qtbot,
timer,
Expand Down Expand Up @@ -228,6 +233,7 @@ def test_foo(qtbot):
]
),
)
@flaky_on_macos
def test_signal_triggered_multiple(
qtbot,
timer,
Expand Down Expand Up @@ -1000,43 +1006,6 @@ def test_without_callback_and_args(self, qtbot, signaller):
ex_msg = TestWaitSignalsTimeoutErrorMessage.get_exception_message(excinfo)
assert ex_msg == "Signal signal() not emitted after 200 ms"

def test_unable_to_get_callback_name(self, qtbot, signaller):
"""
Test that for complicated callbacks which aren't callables, but e.g. double-wrapped partials, the test code
is sometimes unable to determine the name of the callback.
Note that this behavior changes with Python 3.5, where a functools.partial() is smart enough to detect wrapped
calls.
"""
if sys.version_info >= (3, 5):
pytest.skip(
"Only on Python 3.4 and lower double-wrapped functools.partial callbacks are a problem"
)

if qt_api.pytest_qt_api == "pyside2":
signal = (signaller.signal_single_arg, "signal_single_arg(int)")
else:
signal = signaller.signal_single_arg

def callback(int_param, unused_param1, unused_param2):
return int_param == 1337

wrapped_callback = functools.partial(callback, unused_param2=1)
double_wrapped_callback = functools.partial(wrapped_callback, unused_param1=1)

with pytest.raises(TimeoutError) as excinfo:
with qtbot.waitSignal(
signal=signal,
timeout=200,
raising=True,
check_params_cb=double_wrapped_callback,
):
signaller.signal_single_arg.emit(1)
ex_msg = TestWaitSignalsTimeoutErrorMessage.get_exception_message(excinfo)
assert ex_msg == (
"Signal signal_single_arg(int) emitted with parameters [1] within 200 ms, "
"but did not satisfy the callback"
)

def test_with_single_arg(self, qtbot, signaller):
"""
In a situation where a signal with one argument is expected but the emitted instances have values that are
Expand Down