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).
This commit is contained in:
Ben Darnell 2014-05-18 20:34:30 -04:00
parent 5a9333d506
commit db91773328
2 changed files with 17 additions and 2 deletions

View File

@ -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")

14
tox.ini
View File

@ -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 =