diff options
Diffstat (limited to 'tests/unit/misc/test_ipc.py')
-rw-r--r-- | tests/unit/misc/test_ipc.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index 1bd6e4695..445dab614 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -56,7 +56,7 @@ def ipc_server(qapp, qtbot): server = ipc.IPCServer('qute-test') yield server if (server._socket is not None and - server._socket.state() != QLocalSocket.UnconnectedState): + server._socket.state() != QLocalSocket.LocalSocketState.UnconnectedState): with qtbot.wait_signal(server._socket.disconnected, raising=False): server._socket.abort() try: @@ -78,7 +78,7 @@ def qlocalsocket(qapp): socket = QLocalSocket() yield socket socket.disconnectFromServer() - if socket.state() != QLocalSocket.UnconnectedState: + if socket.state() != QLocalSocket.LocalSocketState.UnconnectedState: socket.waitForDisconnected(1000) @@ -103,7 +103,7 @@ class FakeSocket(QObject): readyRead = pyqtSignal() # noqa: N815 disconnected = pyqtSignal() - def __init__(self, *, error=QLocalSocket.UnknownSocketError, state=None, + def __init__(self, *, error=QLocalSocket.LocalSocketError.UnknownSocketError, state=None, data=None, connect_successful=True, parent=None): super().__init__(parent) self._error_val = error @@ -280,9 +280,9 @@ class TestExceptions: raise exc def test_socket_error(self, qlocalserver): - socket = FakeSocket(error=QLocalSocket.ConnectionRefusedError) + socket = FakeSocket(error=QLocalSocket.LocalSocketError.ConnectionRefusedError) exc = ipc.SocketError("testing", socket) - assert exc.code == QLocalSocket.ConnectionRefusedError + assert exc.code == QLocalSocket.LocalSocketError.ConnectionRefusedError assert exc.message == "Error string" assert str(exc) == "Error while testing: Error string (error 0)" @@ -322,7 +322,7 @@ class TestListen: @pytest.mark.windows def test_permissions_windows(self, ipc_server): opts = ipc_server._server.socketOptions() - assert opts == QLocalServer.UserAccessOption + assert opts == QLocalServer.SocketOption.UserAccessOption @pytest.mark.posix def test_permissions_posix(self, ipc_server): @@ -406,21 +406,21 @@ class TestOnError: ipc_server._socket = QLocalSocket() ipc_server._timer.timeout.disconnect() ipc_server._timer.start() - ipc_server.on_error(QLocalSocket.PeerClosedError) + ipc_server.on_error(QLocalSocket.LocalSocketError.PeerClosedError) assert not ipc_server._timer.isActive() def test_other_error(self, ipc_server, monkeypatch): socket = QLocalSocket() ipc_server._socket = socket monkeypatch.setattr(socket, 'error', - lambda: QLocalSocket.ConnectionRefusedError) + lambda: QLocalSocket.LocalSocketError.ConnectionRefusedError) monkeypatch.setattr(socket, 'errorString', lambda: "Connection refused") socket.setErrorString("Connection refused.") with pytest.raises(ipc.Error, match=r"Error while handling IPC " r"connection: Connection refused \(error 0\)"): - ipc_server.on_error(QLocalSocket.ConnectionRefusedError) + ipc_server.on_error(QLocalSocket.LocalSocketError.ConnectionRefusedError) class TestHandleConnection: @@ -444,13 +444,13 @@ class TestHandleConnection: assert any(message.startswith(msg) for message in caplog.messages) def test_disconnected_immediately(self, ipc_server, caplog): - socket = FakeSocket(state=QLocalSocket.UnconnectedState) + socket = FakeSocket(state=QLocalSocket.LocalSocketState.UnconnectedState) ipc_server._server = FakeServer(socket) ipc_server.handle_connection() assert "Socket was disconnected immediately." in caplog.messages def test_error_immediately(self, ipc_server, caplog): - socket = FakeSocket(error=QLocalSocket.ConnectionError) + socket = FakeSocket(error=QLocalSocket.LocalSocketError.ConnectionError) ipc_server._server = FakeServer(socket) with pytest.raises(ipc.Error, match=r"Error while handling IPC " @@ -588,7 +588,7 @@ class TestSendToRunningInstance: assert parsed == raw_expected def test_socket_error(self): - socket = FakeSocket(error=QLocalSocket.ConnectionError) + socket = FakeSocket(error=QLocalSocket.LocalSocketError.ConnectionError) with pytest.raises(ipc.Error, match=r"Error while writing to running " r"instance: Error string \(error 7\)"): ipc.send_to_running_instance('qute-test', [], None, socket=socket) @@ -598,7 +598,7 @@ class TestSendToRunningInstance: ipc.send_to_running_instance('qute-test', [], None, socket=socket) def test_socket_error_no_server(self): - socket = FakeSocket(error=QLocalSocket.ConnectionError, + socket = FakeSocket(error=QLocalSocket.LocalSocketError.ConnectionError, connect_successful=False) with pytest.raises(ipc.Error, match=r"Error while connecting to " r"running instance: Error string \(error 7\)"): @@ -701,14 +701,14 @@ class TestSendOrListen: -> success """ qlocalserver_mock().listen.return_value = False - err = QAbstractSocket.AddressInUseError + err = QAbstractSocket.SocketError.AddressInUseError qlocalserver_mock().serverError.return_value = err qlocalsocket_mock().waitForConnected.side_effect = [False, True] qlocalsocket_mock().error.side_effect = [ - QLocalSocket.ServerNotFoundError, - QLocalSocket.UnknownSocketError, - QLocalSocket.UnknownSocketError, # error() gets called twice + QLocalSocket.LocalSocketError.ServerNotFoundError, + QLocalSocket.LocalSocketError.UnknownSocketError, + QLocalSocket.LocalSocketError.UnknownSocketError, # error() gets called twice ] ret = ipc.send_or_listen(args) @@ -734,17 +734,17 @@ class TestSendOrListen: -> not sent / error """ qlocalserver_mock().listen.return_value = False - err = QAbstractSocket.AddressInUseError + err = QAbstractSocket.SocketError.AddressInUseError qlocalserver_mock().serverError.return_value = err # If the second connection succeeds, we will have an error later. # If it fails, that's the "not sent" case above. qlocalsocket_mock().waitForConnected.side_effect = [False, has_error] qlocalsocket_mock().error.side_effect = [ - QLocalSocket.ServerNotFoundError, - QLocalSocket.ServerNotFoundError, - QLocalSocket.ConnectionRefusedError, - QLocalSocket.ConnectionRefusedError, # error() gets called twice + QLocalSocket.LocalSocketError.ServerNotFoundError, + QLocalSocket.LocalSocketError.ServerNotFoundError, + QLocalSocket.LocalSocketError.ConnectionRefusedError, + QLocalSocket.LocalSocketError.ConnectionRefusedError, # error() gets called twice ] with caplog.at_level(logging.ERROR): @@ -766,7 +766,7 @@ class TestSendOrListen: def test_error_while_listening(self, qlocalserver_mock, caplog, args): """Test an error with the first listen call.""" qlocalserver_mock().listen.return_value = False - err = QAbstractSocket.SocketResourceError + err = QAbstractSocket.SocketError.SocketResourceError qlocalserver_mock().serverError.return_value = err with caplog.at_level(logging.ERROR): @@ -809,7 +809,7 @@ def test_connect_inexistent(qlocalsocket): would not work properly. """ qlocalsocket.connectToServer('qute-test-inexistent') - assert qlocalsocket.error() == QLocalSocket.ServerNotFoundError + assert qlocalsocket.error() == QLocalSocket.LocalSocketError.ServerNotFoundError @pytest.mark.posix @@ -826,7 +826,7 @@ def test_socket_options_address_in_use_problem(qlocalserver, short_tmpdir): assert ok s2 = QLocalServer() - s2.setSocketOptions(QLocalServer.UserAccessOption) + s2.setSocketOptions(QLocalServer.SocketOption.UserAccessOption) ok = s2.listen(servername) print(s2.errorString()) # We actually would expect ok == False here - but we want the test to fail |