Only use IPv4 127.0.0.1 for tests

Fix #331
This commit is contained in:
Michał Trojnara 2023-12-21 11:33:48 +01:00
parent 98b004edda
commit 4d08fbb2c1
3 changed files with 5 additions and 5 deletions

View File

@ -15,7 +15,7 @@ def main() -> None:
try: try:
with open(PORT_LOG, 'r') as file: with open(PORT_LOG, 'r') as file:
port = file.readline() port = file.readline()
conn = http.client.HTTPConnection('localhost', port) conn = http.client.HTTPConnection('127.0.0.1', port)
conn.request('POST', '/kill_server') conn.request('POST', '/kill_server')
response = conn.getresponse() response = conn.getresponse()
print("HTTP status code:", response.getcode(), end=', ') print("HTTP status code:", response.getcode(), end=', ')

View File

@ -95,8 +95,8 @@ class HttpServerThread():
self.server_thread = None self.server_thread = None
def start_server(self, port) -> (int): def start_server(self, port) -> (int):
"""Starting HTTP server on localhost and a random available port for binding""" """Starting HTTP server on 127.0.0.1 and a random available port for binding"""
self.server = ThreadingHTTPServer(('localhost', port), RequestHandler) self.server = ThreadingHTTPServer(('127.0.0.1', port), RequestHandler)
self.server_thread = threading.Thread(target=self.server.serve_forever) self.server_thread = threading.Thread(target=self.server.serve_forever)
self.server_thread.start() self.server_thread.start()
hostname, port = self.server.server_address[:2] hostname, port = self.server.server_address[:2]

View File

@ -95,8 +95,8 @@ class HttpServerThread():
self.server_thread = None self.server_thread = None
def start_server(self) -> (int): def start_server(self) -> (int):
"""Starting HTTP server on localhost and a random available port for binding""" """Starting HTTP server on 127.0.0.1 and a random available port for binding"""
self.server = ThreadingHTTPServer(('localhost', 19254), RequestHandler) self.server = ThreadingHTTPServer(('127.0.0.1', 19254), RequestHandler)
self.server_thread = threading.Thread(target=self.server.serve_forever) self.server_thread = threading.Thread(target=self.server.serve_forever)
self.server_thread.start() self.server_thread.start()
hostname, port = self.server.server_address[:2] hostname, port = self.server.server_address[:2]