Commit d336b1c8 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-11617: Try to strengthen test_httpservers (GH-11121)

(cherry picked from commit cb342182)
parent d0d09b51
...@@ -55,8 +55,8 @@ class TestServerThread(threading.Thread): ...@@ -55,8 +55,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:
...@@ -84,7 +84,7 @@ class BaseTestCase(unittest.TestCase): ...@@ -84,7 +84,7 @@ class BaseTestCase(unittest.TestCase):
test_support.threading_cleanup(*self._threads) test_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 = httplib.HTTPConnection('localhost', self.PORT) self.connection = httplib.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()
...@@ -187,7 +187,7 @@ class BaseHTTPServerTestCase(BaseTestCase): ...@@ -187,7 +187,7 @@ class BaseHTTPServerTestCase(BaseTestCase):
def setUp(self): def setUp(self):
BaseTestCase.setUp(self) BaseTestCase.setUp(self)
self.con = httplib.HTTPConnection('localhost', self.PORT) self.con = httplib.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