Commit a5b9096e authored by Jason Madden's avatar Jason Madden

Fix cares tests on py2

parent 2373a502
......@@ -112,7 +112,7 @@ def _patch_dns():
def extra_all(mod_name):
return extras.get(mod_name, ())
def after_import_hook(dns): # pylint;disable=redefined-outer-name
def after_import_hook(dns): # pylint:disable=redefined-outer-name
# Runs while still in the original patching scope.
# The dns.rdata:get_rdata_class() function tries to
# dynamically import modules using __import__ and then walk
......
......@@ -10,8 +10,9 @@ from gevent.tests.test__socket_dns import TestCase, add
from gevent.testing.sysinfo import OSX
from gevent.testing.sysinfo import RESOLVER_DNSPYTHON
from gevent.testing.sysinfo import RESOLVER_ARES
from gevent.testing.sysinfo import PYPY
from gevent.testing.sysinfo import PY2
# We can't control the DNS servers on CI (or in general...)
# for the system. This works best with the google DNS servers
......@@ -45,6 +46,18 @@ class Test6(TestCase):
# of the system and ares. They don't match exactly.
return ()
if RESOLVER_ARES and PY2:
def _normalize_result_getnameinfo(self, result):
# Beginning 2020-07-23,
# c-ares returns a scope id on the result:
# ('2001:470:1:18::115%0', 'http')
# The standard library does not (on linux or os x).
# I've only seen '%0', so only remove that
ipaddr, service = result
if ipaddr.endswith('%0'):
ipaddr = ipaddr[:-2]
return (ipaddr, service)
if not OSX and RESOLVER_DNSPYTHON:
# It raises gaierror instead of socket.error,
# which is not great and leads to failures.
......
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