Don't use QSignalSpy in IPC test
Fixes #1727. For another testcase in the same file we still need to use it until pytest-qt has a MultiSignalBlocker.args.
This commit is contained in:
parent
b51640f26d
commit
483072d842
@ -533,32 +533,33 @@ class TestSendToRunningInstance:
|
||||
@pytest.mark.linux(reason="Causes random trouble on Windows and OS X")
|
||||
def test_normal(self, qtbot, tmpdir, ipc_server, mocker, has_cwd):
|
||||
ipc_server.listen()
|
||||
raw_spy = QSignalSpy(ipc_server.got_raw)
|
||||
|
||||
with qtbot.assertNotEmitted(ipc_server.got_invalid_data):
|
||||
with qtbot.waitSignal(ipc_server.got_args,
|
||||
timeout=5000) as blocker:
|
||||
with tmpdir.as_cwd():
|
||||
if not has_cwd:
|
||||
m = mocker.patch('qutebrowser.misc.ipc.os')
|
||||
m.getcwd.side_effect = OSError
|
||||
sent = ipc.send_to_running_instance('qute-test', ['foo'],
|
||||
None)
|
||||
with qtbot.waitSignal(ipc_server.got_raw,
|
||||
timeout=5000) as raw_blocker:
|
||||
with tmpdir.as_cwd():
|
||||
if not has_cwd:
|
||||
m = mocker.patch('qutebrowser.misc.ipc.os')
|
||||
m.getcwd.side_effect = OSError
|
||||
sent = ipc.send_to_running_instance(
|
||||
'qute-test', ['foo'], None)
|
||||
|
||||
assert sent
|
||||
assert sent
|
||||
|
||||
expected_cwd = str(tmpdir) if has_cwd else ''
|
||||
|
||||
assert blocker.args == [['foo'], '', expected_cwd]
|
||||
|
||||
assert len(raw_spy) == 1
|
||||
assert len(raw_spy[0]) == 1
|
||||
raw_expected = {'args': ['foo'], 'target_arg': None,
|
||||
'version': qutebrowser.__version__,
|
||||
'protocol_version': ipc.PROTOCOL_VERSION}
|
||||
if has_cwd:
|
||||
raw_expected['cwd'] = str(tmpdir)
|
||||
parsed = json.loads(raw_spy[0][0].decode('utf-8'))
|
||||
|
||||
assert len(raw_blocker.args) == 1
|
||||
parsed = json.loads(raw_blocker.args[0].decode('utf-8'))
|
||||
assert parsed == raw_expected
|
||||
|
||||
def test_socket_error(self):
|
||||
|
Loading…
Reference in New Issue
Block a user