From 0445dc38ccd6c0bfd2f9d4c6a179ab5db56b9208 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sun, 20 Oct 2019 17:37:37 +0200 Subject: [PATCH] fix test_serverStopsWhileConnected --- boswatch/network/client.py | 2 ++ test/boswatch/test_ServerClient.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/boswatch/network/client.py b/boswatch/network/client.py index b045d24..33db246 100644 --- a/boswatch/network/client.py +++ b/boswatch/network/client.py @@ -122,5 +122,7 @@ class TCPClient: self._sock.sendall(bytes(header + aliveMsg, "utf-8")) return True except (AttributeError, BrokenPipeError): + logging.exception("Unknown error: ") + except ConnectionResetError: pass return False diff --git a/test/boswatch/test_ServerClient.py b/test/boswatch/test_ServerClient.py index 9c5fd00..93f7b39 100644 --- a/test/boswatch/test_ServerClient.py +++ b/test/boswatch/test_ServerClient.py @@ -164,9 +164,12 @@ def test_serverStopsWhileConnected(getRunningServer, getClient): """!Shutdown server while client is connected""" getClient.connect() getRunningServer.stop() - time.sleep(0.1) - assert getClient.isConnected # todo check why the first always return true here - assert not getClient.isConnected + timeout = 10 + while getClient.isConnected: + print(timeout) + timeout = timeout - 1 + if timeout is 0: + assert 0 @pytest.mark.skip("needs fixture for more than one client")