]> granicus.if.org Git - python/commitdiff
Try to strengthen test_httpservers (issue #11617)
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 20 Mar 2011 23:26:51 +0000 (00:26 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 20 Mar 2011 23:26:51 +0000 (00:26 +0100)
Lib/test/test_httpservers.py

index a16e0e32b883dcb4e549a0ccaebf275e85e2727a..39ebc263381fc4b48d33189f3b97d35c79a3d0f8 100644 (file)
@@ -38,8 +38,8 @@ class TestServerThread(threading.Thread):
         self.test_object = test_object
 
     def run(self):
-        self.server = HTTPServer(('', 0), self.request_handler)
-        self.test_object.PORT = self.server.socket.getsockname()[1]
+        self.server = HTTPServer(('localhost', 0), self.request_handler)
+        self.test_object.HOST, self.test_object.PORT = self.server.socket.getsockname()
         self.test_object.server_started.set()
         self.test_object = None
         try:
@@ -66,7 +66,7 @@ class BaseTestCase(unittest.TestCase):
         support.threading_cleanup(*self._threads)
 
     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)
         return self.connection.getresponse()
 
@@ -107,7 +107,7 @@ class BaseHTTPServerTestCase(BaseTestCase):
 
     def 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()
 
     def test_command(self):