Commit cb342182 authored by Antoine Pitrou's avatar Antoine Pitrou

Try to strengthen test_httpservers (issue #11617)

parent 7903cb72
...@@ -38,8 +38,8 @@ class TestServerThread(threading.Thread): ...@@ -38,8 +38,8 @@ class TestServerThread(threading.Thread):
self.test_object = test_object self.test_object = test_object
def run(self): def run(self):
self.server = HTTPServer(('', 0), self.request_handler) self.server = HTTPServer(('localhost', 0), self.request_handler)
self.test_object.PORT = self.server.socket.getsockname()[1] self.test_object.HOST, self.test_object.PORT = self.server.socket.getsockname()
self.test_object.server_started.set() self.test_object.server_started.set()
self.test_object = None self.test_object = None
try: try:
...@@ -66,7 +66,7 @@ class BaseTestCase(unittest.TestCase): ...@@ -66,7 +66,7 @@ class BaseTestCase(unittest.TestCase):
support.threading_cleanup(*self._threads) support.threading_cleanup(*self._threads)
def request(self, uri, method='GET', body=None, headers={}): def request(self, uri, method='GET', body=None, headers={}):
self.connection = http.client.HTTPConnection('localhost', self.PORT) self.connection = http.client.HTTPConnection(self.HOST, self.PORT)
self.connection.request(method, uri, body, headers) self.connection.request(method, uri, body, headers)
return self.connection.getresponse() return self.connection.getresponse()
...@@ -107,7 +107,7 @@ class BaseHTTPServerTestCase(BaseTestCase): ...@@ -107,7 +107,7 @@ class BaseHTTPServerTestCase(BaseTestCase):
def setUp(self): def setUp(self):
BaseTestCase.setUp(self) BaseTestCase.setUp(self)
self.con = http.client.HTTPConnection('localhost', self.PORT) self.con = http.client.HTTPConnection(self.HOST, self.PORT)
self.con.connect() self.con.connect()
def test_command(self): def test_command(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment