From: Ben Darnell Date: Mon, 19 May 2014 00:34:30 +0000 (-0400) Subject: Use Resolver instead of socket.getaddrinfo to decide whether localhost is ipv6. X-Git-Tag: v4.0.0b1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db91773328d3feee4177ad9d55203cffdb118ad8;p=thirdparty%2Ftornado.git Use Resolver instead of socket.getaddrinfo to decide whether localhost is ipv6. The results can differ with different resolvers. Add a CaresResolver configuration to tox (it was already in travis). --- diff --git a/tornado/test/tcpclient_test.py b/tornado/test/tcpclient_test.py index 402488c3f..a12f5aafd 100644 --- a/tornado/test/tcpclient_test.py +++ b/tornado/test/tcpclient_test.py @@ -67,8 +67,9 @@ class TCPClientTest(AsyncTestCase): super(TCPClientTest, self).tearDown() def skipIfLocalhostV4(self): - families = set(sockaddr[0] - for sockaddr in socket.getaddrinfo('localhost', 0)) + Resolver().resolve('localhost', 0, callback=self.stop) + addrinfo = self.wait() + families = set(addr[0] for addr in addrinfo) if socket.AF_INET6 not in families: self.skipTest("localhost does not resolve to ipv6") diff --git a/tox.ini b/tox.ini index 3f3857276..65b150ae3 100644 --- a/tox.ini +++ b/tox.ini @@ -31,6 +31,9 @@ envlist = py2-twisted, py26-twisted, py2-twistedlayered, py3-asyncio, py33-asyncio, py26-trollius, py2-trollius, + # Alternate Resolvers. + py2-caresresolver, py3-caresresolver, + # Other configurations; see comments below. py2-monotonic, py3-monotonic, py2-opt, py3-opt, @@ -206,6 +209,17 @@ deps = trollius>=0.1.3 commands = python -m tornado.test.runtests --ioloop=tornado.platform.asyncio.AsyncIOLoop {posargs:} +[testenv:py2-caresresolver] +basepython = python2.7 +deps = {[testenv:py27-full]deps} +commands = python -m tornado.test.runtests --resolver=tornado.platform.caresresolver.CaresResolver {posargs:} + +[testenv:py3-caresresolver] +# pycares does not install on python 3.3+ +basepython = python3.2 +deps = {[testenv:py32-full]deps} +commands = python -m tornado.test.runtests --resolver=tornado.platform.caresresolver.CaresResolver {posargs:} + [testenv:py2-monotonic] basepython = python2.7 deps =