From 4d08fbb2c1d17b28c45d75c9294417b9ef5209d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Trojnara?= Date: Thu, 21 Dec 2023 11:33:48 +0100 Subject: [PATCH] Only use IPv4 127.0.0.1 for tests Fix #331 --- tests/client_http.py | 2 +- tests/server_http.py | 4 ++-- tests/server_http.pyw | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/client_http.py b/tests/client_http.py index ecf6269..0a2126f 100644 --- a/tests/client_http.py +++ b/tests/client_http.py @@ -15,7 +15,7 @@ def main() -> None: try: with open(PORT_LOG, 'r') as file: port = file.readline() - conn = http.client.HTTPConnection('localhost', port) + conn = http.client.HTTPConnection('127.0.0.1', port) conn.request('POST', '/kill_server') response = conn.getresponse() print("HTTP status code:", response.getcode(), end=', ') diff --git a/tests/server_http.py b/tests/server_http.py index bf0a0a5..6848172 100644 --- a/tests/server_http.py +++ b/tests/server_http.py @@ -95,8 +95,8 @@ class HttpServerThread(): self.server_thread = None def start_server(self, port) -> (int): - """Starting HTTP server on localhost and a random available port for binding""" - self.server = ThreadingHTTPServer(('localhost', port), RequestHandler) + """Starting HTTP server on 127.0.0.1 and a random available port for binding""" + self.server = ThreadingHTTPServer(('127.0.0.1', port), RequestHandler) self.server_thread = threading.Thread(target=self.server.serve_forever) self.server_thread.start() hostname, port = self.server.server_address[:2] diff --git a/tests/server_http.pyw b/tests/server_http.pyw index 07f8311..a1d006c 100644 --- a/tests/server_http.pyw +++ b/tests/server_http.pyw @@ -95,8 +95,8 @@ class HttpServerThread(): self.server_thread = None def start_server(self) -> (int): - """Starting HTTP server on localhost and a random available port for binding""" - self.server = ThreadingHTTPServer(('localhost', 19254), RequestHandler) + """Starting HTTP server on 127.0.0.1 and a random available port for binding""" + self.server = ThreadingHTTPServer(('127.0.0.1', 19254), RequestHandler) self.server_thread = threading.Thread(target=self.server.serve_forever) self.server_thread.start() hostname, port = self.server.server_address[:2]