Use order='strict' with qtbot.waitSignals

See #1702
This commit is contained in:
Florian Bruhin 2016-07-29 07:35:16 +02:00
parent a7e9b4e5d7
commit 4bf94f3c24
5 changed files with 26 additions and 16 deletions

View File

@ -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

View File

@ -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,

View File

@ -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)

View File

@ -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

View File

@ -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