Change IPC warnings to debug.

This seems to show up on Ubuntu Trusty (with older Qt) as well...
This commit is contained in:
Florian Bruhin 2015-11-01 22:25:04 +01:00
parent b79ccb5e79
commit 4451165a27
2 changed files with 12 additions and 15 deletions

View File

@ -226,12 +226,7 @@ class IPCServer(QObject):
"""Raise SocketError on fatal errors."""
if self._socket is None:
# Sometimes this gets called from stale sockets.
msg = "In on_error with None socket!"
if os.name == 'nt': # pragma: no cover
# This happens a lot on Windows, so we ignore it there.
log.ipc.debug(msg)
else:
log.ipc.warning(msg)
log.ipc.debug("In on_error with None socket!")
return
self._timer.stop()
log.ipc.debug("Socket error {}: {}".format(
@ -275,7 +270,7 @@ class IPCServer(QObject):
log.ipc.debug("Client disconnected.")
self._timer.stop()
if self._socket is None:
log.ipc.warning("In on_disconnected with None socket!")
log.ipc.debug("In on_disconnected with None socket!")
else:
self._socket.deleteLater()
self._socket = None

View File

@ -615,21 +615,23 @@ def test_timeout(qtbot, caplog, qlocalsocket, ipc_server):
assert caplog.records()[-1].message == "IPC connection timed out."
@pytest.mark.parametrize('method, args', [
pytest.mark.posix(('on_error', [0])),
('on_disconnected', []),
('on_ready_read', []),
@pytest.mark.parametrize('method, args, is_warning', [
pytest.mark.posix(('on_error', [0], False)),
('on_disconnected', [], False),
('on_ready_read', [], True),
])
def test_ipcserver_socket_none(ipc_server, caplog, method, args):
def test_ipcserver_socket_none(ipc_server, caplog, method, args, is_warning):
func = getattr(ipc_server, method)
assert ipc_server._socket is None
with caplog.atLevel(logging.WARNING):
if is_warning:
with caplog.atLevel(logging.WARNING):
func(*args)
else:
func(*args)
records = caplog.records()
msg = "In {} with None socket!".format(method)
assert records[-1].message == msg
assert msg in [r.message for r in caplog.records()]
class TestSendOrListen: