From 4bf94f3c24bd179a9a2eb0653461d7046d6b3a0a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 29 Jul 2016 07:35:16 +0200 Subject: [PATCH] Use order='strict' with qtbot.waitSignals See #1702 --- .../webkit/network/test_networkreply.py | 4 ++-- tests/unit/browser/webkit/test_history.py | 7 ++++--- tests/unit/misc/test_guiprocess.py | 18 ++++++++++++------ tests/unit/misc/test_ipc.py | 5 +++-- tests/unit/utils/usertypes/test_question.py | 8 +++++--- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/unit/browser/webkit/network/test_networkreply.py b/tests/unit/browser/webkit/network/test_networkreply.py index a270eebc3..7a9c89393 100644 --- a/tests/unit/browser/webkit/network/test_networkreply.py +++ b/tests/unit/browser/webkit/network/test_networkreply.py @@ -53,7 +53,7 @@ class TestFixedDataNetworkReply: def test_data(self, qtbot, req, data): reply = networkreply.FixedDataNetworkReply(req, data, 'test/foo') with qtbot.waitSignals([reply.metaDataChanged, reply.readyRead, - reply.finished]): + reply.finished], order='strict'): pass assert reply.bytesAvailable() == len(data) @@ -78,7 +78,7 @@ def test_error_network_reply(qtbot, req): reply = networkreply.ErrorNetworkReply( req, "This is an error", QNetworkReply.UnknownNetworkError) - with qtbot.waitSignals([reply.error, reply.finished]): + with qtbot.waitSignals([reply.error, reply.finished], order='strict'): pass reply.abort() # shouldn't do anything diff --git a/tests/unit/browser/webkit/test_history.py b/tests/unit/browser/webkit/test_history.py index 2aabd7b54..3da69e9f0 100644 --- a/tests/unit/browser/webkit/test_history.py +++ b/tests/unit/browser/webkit/test_history.py @@ -88,7 +88,7 @@ def test_adding_item_during_async_read(qtbot, hist, redirect): list(hist.async_read()) else: with qtbot.waitSignals([hist.add_completion_item, - hist.async_read_done]): + hist.async_read_done], order='strict'): list(hist.async_read()) assert not hist._temp_history @@ -112,7 +112,7 @@ def test_private_browsing(qtbot, tmpdir, fake_save_manager, config_stub): # read with qtbot.assertNotEmitted(private_hist.add_completion_item), \ qtbot.assertNotEmitted(private_hist.item_added): - with qtbot.waitSignals([private_hist.async_read_done]): + with qtbot.waitSignals([private_hist.async_read_done], order='strict'): list(private_hist.async_read()) # after read @@ -246,7 +246,8 @@ def test_add_item(qtbot, hist): list(hist.async_read()) url = 'http://www.example.com/' - with qtbot.waitSignals([hist.add_completion_item, hist.item_added]): + with qtbot.waitSignals([hist.add_completion_item, hist.item_added], + order='strict'): hist.add_url(QUrl(url), atime=12345, title="the title") entry = history.Entry(url=QUrl(url), redirect=False, atime=12345, diff --git a/tests/unit/misc/test_guiprocess.py b/tests/unit/misc/test_guiprocess.py index ce4e3fa7e..421ab815b 100644 --- a/tests/unit/misc/test_guiprocess.py +++ b/tests/unit/misc/test_guiprocess.py @@ -57,7 +57,8 @@ def fake_proc(monkeypatch, stubs): def test_start(proc, qtbot, guiprocess_message_mock, py_proc): """Test simply starting a process.""" - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000): + with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + order='strict'): argv = py_proc("import sys; print('test'); sys.exit(0)") proc.start(*argv) @@ -69,7 +70,8 @@ def test_start_verbose(proc, qtbot, guiprocess_message_mock, py_proc): """Test starting a process verbosely.""" proc.verbose = True - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000): + with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + order='strict'): argv = py_proc("import sys; print('test'); sys.exit(0)") proc.start(*argv) @@ -96,7 +98,8 @@ def test_start_env(monkeypatch, qtbot, py_proc): sys.exit(0) """) - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000): + with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + order='strict'): proc.start(*argv) data = bytes(proc._proc.readAll()).decode('utf-8') @@ -108,7 +111,8 @@ def test_start_env(monkeypatch, qtbot, py_proc): @pytest.mark.qt_log_ignore('QIODevice::read.*: WriteOnly device') def test_start_mode(proc, qtbot, py_proc): """Test simply starting a process with mode parameter.""" - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000): + with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + order='strict'): argv = py_proc("import sys; print('test'); sys.exit(0)") proc.start(*argv, mode=QIODevice.NotOpen) @@ -145,10 +149,12 @@ def test_double_start(qtbot, proc, py_proc): def test_double_start_finished(qtbot, proc, py_proc): """Test starting a GUIProcess twice (with the first call finished).""" - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000): + with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + order='strict'): argv = py_proc("import sys; sys.exit(0)") proc.start(*argv) - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000): + with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + order='strict'): argv = py_proc("import sys; sys.exit(0)") proc.start(*argv) diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index faf23edf0..475cc36e8 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -494,7 +494,7 @@ def test_invalid_data(qtbot, ipc_server, connected_socket, caplog, data, msg): signals = [ipc_server.got_invalid_data, connected_socket.disconnected] with caplog.at_level(logging.ERROR): with qtbot.assertNotEmitted(ipc_server.got_args): - with qtbot.waitSignals(signals): + with qtbot.waitSignals(signals, order='strict'): connected_socket.write(data) messages = [r.message for r in caplog.records] @@ -512,7 +512,8 @@ def test_multiline(qtbot, ipc_server, connected_socket): version=ipc.PROTOCOL_VERSION)) with qtbot.assertNotEmitted(ipc_server.got_invalid_data): - with qtbot.waitSignals([ipc_server.got_args, ipc_server.got_args]): + with qtbot.waitSignals([ipc_server.got_args, ipc_server.got_args], + order='strict'): connected_socket.write(data.encode('utf-8')) assert len(spy) == 2 diff --git a/tests/unit/utils/usertypes/test_question.py b/tests/unit/utils/usertypes/test_question.py index edd4c1081..119d4ee3f 100644 --- a/tests/unit/utils/usertypes/test_question.py +++ b/tests/unit/utils/usertypes/test_question.py @@ -61,21 +61,23 @@ def test_done(mode, answer, signal_names, question, qtbot): question.mode = mode question.answer = answer signals = [getattr(question, name) for name in signal_names] - with qtbot.waitSignals(signals): + with qtbot.waitSignals(signals, order='strict'): question.done() assert not question.is_aborted def test_cancel(question, qtbot): """Test Question.cancel().""" - with qtbot.waitSignals([question.cancelled, question.completed]): + with qtbot.waitSignals([question.cancelled, question.completed], + order='strict'): question.cancel() assert not question.is_aborted def test_abort(question, qtbot): """Test Question.abort().""" - with qtbot.waitSignals([question.aborted, question.completed]): + with qtbot.waitSignals([question.aborted, question.completed], + order='strict'): question.abort() assert question.is_aborted