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,17 +533,18 @@ class TestSendToRunningInstance:
|
|||||||
@pytest.mark.linux(reason="Causes random trouble on Windows and OS X")
|
@pytest.mark.linux(reason="Causes random trouble on Windows and OS X")
|
||||||
def test_normal(self, qtbot, tmpdir, ipc_server, mocker, has_cwd):
|
def test_normal(self, qtbot, tmpdir, ipc_server, mocker, has_cwd):
|
||||||
ipc_server.listen()
|
ipc_server.listen()
|
||||||
raw_spy = QSignalSpy(ipc_server.got_raw)
|
|
||||||
|
|
||||||
with qtbot.assertNotEmitted(ipc_server.got_invalid_data):
|
with qtbot.assertNotEmitted(ipc_server.got_invalid_data):
|
||||||
with qtbot.waitSignal(ipc_server.got_args,
|
with qtbot.waitSignal(ipc_server.got_args,
|
||||||
timeout=5000) as blocker:
|
timeout=5000) as blocker:
|
||||||
|
with qtbot.waitSignal(ipc_server.got_raw,
|
||||||
|
timeout=5000) as raw_blocker:
|
||||||
with tmpdir.as_cwd():
|
with tmpdir.as_cwd():
|
||||||
if not has_cwd:
|
if not has_cwd:
|
||||||
m = mocker.patch('qutebrowser.misc.ipc.os')
|
m = mocker.patch('qutebrowser.misc.ipc.os')
|
||||||
m.getcwd.side_effect = OSError
|
m.getcwd.side_effect = OSError
|
||||||
sent = ipc.send_to_running_instance('qute-test', ['foo'],
|
sent = ipc.send_to_running_instance(
|
||||||
None)
|
'qute-test', ['foo'], None)
|
||||||
|
|
||||||
assert sent
|
assert sent
|
||||||
|
|
||||||
@ -551,14 +552,14 @@ class TestSendToRunningInstance:
|
|||||||
|
|
||||||
assert blocker.args == [['foo'], '', expected_cwd]
|
assert blocker.args == [['foo'], '', expected_cwd]
|
||||||
|
|
||||||
assert len(raw_spy) == 1
|
|
||||||
assert len(raw_spy[0]) == 1
|
|
||||||
raw_expected = {'args': ['foo'], 'target_arg': None,
|
raw_expected = {'args': ['foo'], 'target_arg': None,
|
||||||
'version': qutebrowser.__version__,
|
'version': qutebrowser.__version__,
|
||||||
'protocol_version': ipc.PROTOCOL_VERSION}
|
'protocol_version': ipc.PROTOCOL_VERSION}
|
||||||
if has_cwd:
|
if has_cwd:
|
||||||
raw_expected['cwd'] = str(tmpdir)
|
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
|
assert parsed == raw_expected
|
||||||
|
|
||||||
def test_socket_error(self):
|
def test_socket_error(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user