From eebed7a5a7b71c4fb46a0f0e8f92c1c3c89043e1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 8 Jan 2016 09:35:03 +0100 Subject: [PATCH] tests: Poll clipboard for changes. For some reason I can't explain, since 2b0870084b9185b8f8a12639d238c12b202d3284 we got test failures on OS X, as the clipboard had the old value before waiting for the change, the new (correct) value after waiting for it, but never actually emitted 'changed'. We could just re-check the contents after the timeout, but that'd mean we wait 1s for every test where this weird thing happens. Instead, we poll the clipboard for every 100ms as long as the timeout (1s) hasn't passed, and return as soon as it has the correct contents. --- tests/integration/features/conftest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 5d374af77..be2af7cf3 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -395,9 +395,13 @@ def _wait_for_clipboard(qtbot, clipboard, mode, expected): while True: if clipboard.text(mode=mode) == expected: return - with qtbot.waitSignal(clipboard.changed, timeout=timeout) as blocker: + + # We need to poll the clipboard, as for some reason it can change with + # emitting changed (?). + with qtbot.waitSignal(clipboard.changed, timeout=100) as blocker: pass - if not blocker.signal_triggered or timer.hasExpired(timeout): + + if timer.hasExpired(timeout): mode_names = { QClipboard.Clipboard: 'clipboard', QClipboard.Selection: 'primary selection',