diff --git a/boswatch/configYaml.py b/boswatch/configYaml.py index 5a0cab2..74af87e 100644 --- a/boswatch/configYaml.py +++ b/boswatch/configYaml.py @@ -69,5 +69,5 @@ class ConfigYAML: return ConfigYAML(tmp) else: return tmp - except AttributeError: + except AttributeError: # pragma: no cover return default diff --git a/boswatch/network/broadcast.py b/boswatch/network/broadcast.py index c4f8ea6..da6e23b 100644 --- a/boswatch/network/broadcast.py +++ b/boswatch/network/broadcast.py @@ -99,7 +99,7 @@ class BroadcastServer: self._serverShutdown = False self._servePort = servePort - def __del__(self): + def __del__(self): # pragma: no cover if self.isRunning: self.stop() while self.isRunning: diff --git a/boswatch/network/server.py b/boswatch/network/server.py index 8656ef2..0168c7c 100644 --- a/boswatch/network/server.py +++ b/boswatch/network/server.py @@ -135,8 +135,8 @@ class TCPServer: return False else: - logging.error("server always started") - return False + logging.warning("server always started") + return True def stop(self): """!Stops the TCP socket server diff --git a/test/boswatch/test_ServerClient.py b/test/boswatch/test_ServerClient.py index 43287af..617f473 100644 --- a/test/boswatch/test_ServerClient.py +++ b/test/boswatch/test_ServerClient.py @@ -156,8 +156,15 @@ def test_serverStopFailed(getServer): assert getServer.stop() -def test_serverDoubleStart(): +def test_serverDoubleStart(getServer): """!Test to start the server twice""" + assert getServer.start() + assert getServer.start() + assert getServer.stop() + + +def test_serverStartTwoInstances(): + """!Test to start two server different server instances""" dataQueue = queue.Queue() testServer1 = TCPServer(dataQueue) testServer2 = TCPServer(dataQueue) @@ -179,7 +186,8 @@ def test_serverStopsWhileConnected(getRunningServer, getClient): time.sleep(0.1) timeout = timeout - 1 if timeout is 0: - assert 0 + break + assert timeout @pytest.mark.skip("needs fixture for more than one client")