From e79cf82b62cf6a0d75bc9c5392d38dda76ceafa2 Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Sun, 12 Jun 2022 09:07:06 -0400 Subject: [PATCH] Made sure that port 9090 could not be randomly selected. --- tests/step_defs/server.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/step_defs/server.py b/tests/step_defs/server.py index 28f2a2b..fbd93f3 100644 --- a/tests/step_defs/server.py +++ b/tests/step_defs/server.py @@ -30,7 +30,7 @@ class Server: @property def port(self): """Get the port of the server.""" - port = 9090 + port = "9090" if "MTT_PORT" in self.env: port = self.env["MTT_PORT"] return port @@ -68,7 +68,8 @@ class Server: def set_safe_port(self): """Set the server port to something not being used.""" - sock = socket() - sock.bind((self.address, 0)) - self.port = sock.getsockname()[1] - sock.close() + while self.port == "9090": + sock = socket() + sock.bind((self.address, 0)) + self.port = sock.getsockname()[1] + sock.close()