From: Ben Darnell Date: Sun, 1 Jun 2014 22:31:12 +0000 (-0400) Subject: Fix another ipv6 test that was flaky on travis due to port conflicts. X-Git-Tag: v4.0.0b1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c3b360a2140dd4ed85c45a7b25b1897f125ef85;p=thirdparty%2Ftornado.git Fix another ipv6 test that was flaky on travis due to port conflicts. --- diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index cdf248c73..2ba9f75d7 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -15,7 +15,7 @@ from tornado.httpclient import AsyncHTTPClient from tornado.httputil import HTTPHeaders from tornado.ioloop import IOLoop from tornado.log import gen_log, app_log -from tornado.netutil import Resolver +from tornado.netutil import Resolver, bind_sockets from tornado.simple_httpclient import SimpleAsyncHTTPClient, _default_ca_certs from tornado.test.httpclient_test import ChunkHandler, CountdownHandler, HelloWorldHandler from tornado.test import httpclient_test @@ -245,14 +245,16 @@ class SimpleHTTPClientTestMixin(object): @skipIfNoIPv6 def test_ipv6(self): try: - self.http_server.listen(self.get_http_port(), address='::1') + [sock] = bind_sockets(None, '::1', family=socket.AF_INET6) + port = sock.getsockname()[1] + self.http_server.add_socket(sock) except socket.gaierror as e: if e.args[0] == socket.EAI_ADDRFAMILY: # python supports ipv6, but it's not configured on the network # interface, so skip this test. return raise - url = self.get_url("/hello").replace("localhost", "[::1]") + url = '%s://[::1]:%d/hello' % (self.get_protocol(), port) # ipv6 is currently enabled by default but can be disabled self.http_client.fetch(url, self.stop, allow_ipv6=False)