From b7ee19ec70b42dff0747711a5925630fb098b0a6 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 12 Jun 2015 20:39:00 +0300 Subject: [PATCH 1/9] Rename DNS caching methods --- aiohttp/connector.py | 64 ++++++++++++++++++++++++++++++++--------- tests/test_connector.py | 4 +-- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 507ca4c9bbf..659f599bd48 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -384,6 +384,8 @@ def _create_connection(self, req): _SSL_OP_NO_COMPRESSION = getattr(ssl, "OP_NO_COMPRESSION", 0) _SSH_HAS_CREATE_DEFAULT_CONTEXT = hasattr(ssl, 'create_default_context') +_marker = object() + class TCPConnector(BaseConnector): """TCP connector. @@ -400,7 +402,8 @@ class TCPConnector(BaseConnector): """ def __init__(self, *, verify_ssl=True, fingerprint=None, - resolve=False, family=socket.AF_INET, ssl_context=None, + resolve=_marker, cache_dns=_marker, + family=socket.AF_INET, ssl_context=None, **kwargs): super().__init__(**kwargs) @@ -419,10 +422,21 @@ def __init__(self, *, verify_ssl=True, fingerprint=None, self._hashfunc = hashfunc self._fingerprint = fingerprint + if cache_dns is not _marker and resolve is not _marker: + if cache_dns != resolve: + raise ValueError("cashe_dns must agree with resolve") + _cache_dns = cache_dns + elif cache_dns is not _marker: + _cache_dns = cache_dns + elif resolve is not _marker: + _cache_dns = resolve + else: + _cache_dns = False + + self._cache_dns = _cache_dns + self._cached_hosts = {} self._ssl_context = ssl_context self._family = family - self._resolve = resolve - self._resolved_hosts = {} @property def verify_ssl(self): @@ -466,31 +480,55 @@ def family(self): """Socket family like AF_INET.""" return self._family + @property + def cache_dns(self): + """True if local DNS caching is enabled.""" + return self._cache_dns + + @property + def cached_hosts(self): + """Read-only dict of cached DNS record.""" + return MappingProxyType(self._cached_hosts) + + def clear_dns_cache(self, address=None): + """Remove specified host/port or clear all dns local cache.""" + if address is not None: + self._cached_hosts.pop(address, None) + else: + self._cached_hosts.clear() + @property def resolve(self): """Do DNS lookup for host name?""" - return self._resolve + warnings.warn((".resolve property is deprecated, " + "use .cache_dns instead"), + DeprecationWarning, stacklevel=2) + return self._cache_dns @property def resolved_hosts(self): """The dict of (host, port) -> (ipaddr, port) pairs.""" - return MappingProxyType(self._resolved_hosts) + warnings.warn((".resolved_hosts property is deprecated, " + "use .cached_hosts instead"), + DeprecationWarning, stacklevel=2) + return MappingProxyType(self._cached_hosts) def clear_resolved_hosts(self, host=None, port=None): """Remove specified host/port or clear all resolve cache.""" + warnings.warn((".clear_resolved_hosts() is deprecated, " + "use .clear_dns_cache() instead"), + DeprecationWarning, stacklevel=2) if host is not None and port is not None: - key = (host, port) - if key in self._resolved_hosts: - del self._resolved_hosts[key] + self.clear_dns_cache((host, port)) else: - self._resolved_hosts.clear() + self.clear_dns_cache() @asyncio.coroutine def _resolve_host(self, host, port): - if self._resolve: + if self._cache_dns: key = (host, port) - if key not in self._resolved_hosts: + if key not in self._cached_hosts: infos = yield from self._loop.getaddrinfo( host, port, type=socket.SOCK_STREAM, family=self._family) @@ -501,9 +539,9 @@ def _resolve_host(self, host, port): 'host': address[0], 'port': address[1], 'family': family, 'proto': proto, 'flags': socket.AI_NUMERICHOST}) - self._resolved_hosts[key] = hosts + self._cached_hosts[key] = hosts - return list(self._resolved_hosts[key]) + return list(self._cached_hosts[key]) else: return [{'hostname': host, 'host': host, 'port': port, 'family': self._family, 'proto': 0, 'flags': 0}] diff --git a/tests/test_connector.py b/tests/test_connector.py index 53f7a9a6b83..3d84e51b894 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -514,8 +514,8 @@ def test_tcp_connector_fingerprint(self): def test_tcp_connector_clear_resolved_hosts(self): conn = aiohttp.TCPConnector(loop=self.loop) info = object() - conn._resolved_hosts[('localhost', 123)] = info - conn._resolved_hosts[('localhost', 124)] = info + conn._cached_hosts[('localhost', 123)] = info + conn._cached_hosts[('localhost', 124)] = info conn.clear_resolved_hosts('localhost', 123) self.assertEqual( conn.resolved_hosts, {('localhost', 124): info}) From 353778c5530f008f3edeecca7b4fa834e906aabb Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sun, 14 Jun 2015 13:33:26 +0300 Subject: [PATCH 2/9] Work on cache_dns renaming --- aiohttp/connector.py | 15 +++++++++------ tests/test_connector.py | 9 ++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 659f599bd48..e4614e70660 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -490,10 +490,13 @@ def cached_hosts(self): """Read-only dict of cached DNS record.""" return MappingProxyType(self._cached_hosts) - def clear_dns_cache(self, address=None): + def clear_dns_cache(self, host=None, port=None): """Remove specified host/port or clear all dns local cache.""" - if address is not None: - self._cached_hosts.pop(address, None) + if host is not None and port is not None: + self._cached_hosts.pop((host, port), None) + elif host is not None or port is not None: + raise ValueError("either both host and port " + "or none of them are allowed") else: self._cached_hosts.clear() @@ -503,7 +506,7 @@ def resolve(self): warnings.warn((".resolve property is deprecated, " "use .cache_dns instead"), DeprecationWarning, stacklevel=2) - return self._cache_dns + return self.cache_dns @property def resolved_hosts(self): @@ -511,7 +514,7 @@ def resolved_hosts(self): warnings.warn((".resolved_hosts property is deprecated, " "use .cached_hosts instead"), DeprecationWarning, stacklevel=2) - return MappingProxyType(self._cached_hosts) + return self.cached_hosts def clear_resolved_hosts(self, host=None, port=None): """Remove specified host/port or clear all resolve cache.""" @@ -519,7 +522,7 @@ def clear_resolved_hosts(self, host=None, port=None): "use .clear_dns_cache() instead"), DeprecationWarning, stacklevel=2) if host is not None and port is not None: - self.clear_dns_cache((host, port)) + self.clear_dns_cache(host, port) else: self.clear_dns_cache() diff --git a/tests/test_connector.py b/tests/test_connector.py index 3d84e51b894..7de464461ea 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -458,8 +458,15 @@ def test_tcp_connector_ctor(self): conn = aiohttp.TCPConnector(loop=self.loop) self.assertTrue(conn.verify_ssl) self.assertIs(conn.fingerprint, None) - self.assertFalse(conn.resolve) + + with self.assertWarns(DeprecationWarning): + self.assertFalse(conn.resolve) + self.assertFalse(conn.cache_dns) + self.assertEqual(conn.family, socket.AF_INET) + + with self.assertWarns(DeprecationWarning): + self.assertEqual(conn.resolved_hosts, {}) self.assertEqual(conn.resolved_hosts, {}) def test_tcp_connector_ctor_fingerprint_valid(self): From 3939eb83d93f24582659b895a900ef74428d6148 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 20 Jun 2015 13:23:58 +0300 Subject: [PATCH 3/9] More tests --- tests/test_connector.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_connector.py b/tests/test_connector.py index 7de464461ea..127cc10ed8f 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -763,6 +763,24 @@ def test_connector_cookie_deprecation(self): conn = aiohttp.TCPConnector(share_cookies=True, loop=self.loop) conn.close() + def test_ambiguous_ctor_params(self): + with self.assertRaises(ValueError): + aiohttp.TCPConnector(resolve=True, cache_dns=False, loop=self.loop) + + def test_both_resolve_and_cache_dns(self): + conn = aiohttp.TCPConnector(resolve=True, cache_dns=True, + loop=self.loop) + self.assertTrue(conn.cache_dns) + with self.assertWarns(DeprecationWarning): + self.assertTrue(conn.resolve) + + def test_both_cache_dns_only(self): + conn = aiohttp.TCPConnector(cache_dns=True, + loop=self.loop) + self.assertTrue(conn.cache_dns) + with self.assertWarns(DeprecationWarning): + self.assertTrue(conn.resolve) + class TestProxyConnector(unittest.TestCase): From a61d05f455d3d665c14a9d659e613a4d4cecff77 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 20 Jun 2015 13:29:26 +0300 Subject: [PATCH 4/9] More tests --- tests/test_connector.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/test_connector.py b/tests/test_connector.py index 127cc10ed8f..999ab9877b5 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -529,9 +529,29 @@ def test_tcp_connector_clear_resolved_hosts(self): conn.clear_resolved_hosts('localhost', 123) self.assertEqual( conn.resolved_hosts, {('localhost', 124): info}) - conn.clear_resolved_hosts() + with self.assertWarns(DeprecationWarning): + conn.clear_resolved_hosts() self.assertEqual(conn.resolved_hosts, {}) + def test_tcp_connector_clear_dns_cache(self): + conn = aiohttp.TCPConnector(loop=self.loop) + info = object() + conn._cached_hosts[('localhost', 123)] = info + conn._cached_hosts[('localhost', 124)] = info + conn.clear_dns_cache('localhost', 123) + self.assertEqual( + conn.cached_hosts, {('localhost', 124): info}) + conn.clear_dns_cache('localhost', 123) + self.assertEqual( + conn.cached_hosts, {('localhost', 124): info}) + conn.clear_dns_cache() + self.assertEqual(conn.cached_hosts, {}) + + def test_tcp_connector_clear_dns_cache_bad_args(self): + conn = aiohttp.TCPConnector(loop=self.loop) + with self.assertRaises(ValueError): + conn.clear_dns_cache('localhost') + def test_ambigous_verify_ssl_and_ssl_context(self): with self.assertRaises(ValueError): aiohttp.TCPConnector( From c4a701565deaa773eb83b06c727f2a4b7f10cd1d Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 20 Jun 2015 14:02:35 +0300 Subject: [PATCH 5/9] Update doc for reflecting new DNS cache names --- docs/client_reference.rst | 40 +++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/client_reference.rst b/docs/client_reference.rst index 757302dc1f2..5d687d078d1 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -464,7 +464,7 @@ BaseConnector TCPConnector ^^^^^^^^^^^^ -.. class:: TCPConnector(*, verify_ssl=True, fingerprint=None, resolve=False, \ +.. class:: TCPConnector(*, verify_ssl=True, fingerprint=None, cache_dns=False, \ family=socket.AF_INET, \ ssl_context=None, conn_timeout=None, \ keepalive_timeout=30, limit=None, share_cookies=False, \ @@ -492,13 +492,19 @@ TCPConnector .. versionadded:: 0.16 - :param bool resolve: use internal cache for DNS lookups, ``False`` + :param bool cache_dns: use internal cache for DNS lookups, ``False`` by default. Enabling an option *may* speedup connection establishing a bit but may introduce some *side effects* also. + .. versionadded:: 0.17 + + :param bool resolve: alias for *cache_dns* parameter. + + .. deprecated:: 0.17 + :param int family: TCP socket family, ``AF_INET`` by default (*IPv4*). For *IPv6* use ``AF_INET6``. @@ -525,24 +531,34 @@ TCPConnector Read-only property. - .. attribute:: resolve + .. attribute:: cache_dns Use quick lookup in internal *DNS* cache for host names if ``True``. Read-only :class:`bool` property. + .. versionadded:: 0.17 + .. attribute:: resolve - Use quick lookup in internal *DNS* cache for host names if ``True``. + Alias for :attr:`cache_dns`. - Read-only :class:`bool` property. + .. deprecated:: 0.17 - .. attribute:: resolved_hosts + .. attribute:: cached_hosts - The cache of resolved hosts if :attr:`resolve` is enabled. + The cache of resolved hosts if :attr:`cache_dns` is enabled. Read-only :class:`types.MappingProxyType` property. + .. versionadded:: 0.17 + + .. attribute:: resolved_hosts + + Alias for :attr:`cached_hosts` + + .. deprecated:: 0.17 + .. attribute:: fingerprint md5, sha1, or sha256 hash of the expected certificate in DER @@ -553,13 +569,21 @@ TCPConnector .. versionadded:: 0.16 - .. method:: clear_resolved_hosts(self, host=None, port=None) + .. method:: clear_dns_cache(self, host=None, port=None) Clear internal *DNS* cache. Remove specific entry if both *host* and *port* are specified, clear all cache otherwise. + .. versionadded:: 0.17 + + .. method:: clear_resolved_hosts(self, host=None, port=None) + + Alias for :meth:`clear_dns_cache`. + + .. deprecated:: 0.17 + From 1b26860da7dee8e62b346c9bf6562c10b9eeb181 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 20 Jun 2015 14:04:46 +0300 Subject: [PATCH 6/9] Add warning for resolve parameter in TCPConnector ctor --- aiohttp/connector.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index e4614e70660..59e68d53201 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -422,6 +422,11 @@ def __init__(self, *, verify_ssl=True, fingerprint=None, self._hashfunc = hashfunc self._fingerprint = fingerprint + if resolve is not _marker: + warnings.warn(("resolve parameter is deprecated, " + "use cache_dns instead"), + DeprecationWarning, stacklevel=2) + if cache_dns is not _marker and resolve is not _marker: if cache_dns != resolve: raise ValueError("cashe_dns must agree with resolve") From b6ee6d8a8f4be110fb0c020dc97f4c56418d43f4 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 20 Jun 2015 14:05:16 +0300 Subject: [PATCH 7/9] Fix typo --- aiohttp/connector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 59e68d53201..477469fd7fa 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -429,7 +429,7 @@ def __init__(self, *, verify_ssl=True, fingerprint=None, if cache_dns is not _marker and resolve is not _marker: if cache_dns != resolve: - raise ValueError("cashe_dns must agree with resolve") + raise ValueError("cache_dns must agree with resolve") _cache_dns = cache_dns elif cache_dns is not _marker: _cache_dns = cache_dns From 15d7c5bb96c1f8f53d39ffd9f7b577b7dcd6f6b3 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 20 Jun 2015 14:09:35 +0300 Subject: [PATCH 8/9] cache_dns -> dns_cache --- aiohttp/connector.py | 6 +++--- docs/client_reference.rst | 6 +++--- tests/test_connector.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 477469fd7fa..1902d7af95d 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -486,7 +486,7 @@ def family(self): return self._family @property - def cache_dns(self): + def dns_cache(self): """True if local DNS caching is enabled.""" return self._cache_dns @@ -509,9 +509,9 @@ def clear_dns_cache(self, host=None, port=None): def resolve(self): """Do DNS lookup for host name?""" warnings.warn((".resolve property is deprecated, " - "use .cache_dns instead"), + "use .dns_cache instead"), DeprecationWarning, stacklevel=2) - return self.cache_dns + return self.dns_cache @property def resolved_hosts(self): diff --git a/docs/client_reference.rst b/docs/client_reference.rst index 5d687d078d1..383af4ae1fd 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -531,7 +531,7 @@ TCPConnector Read-only property. - .. attribute:: cache_dns + .. attribute:: dns_cache Use quick lookup in internal *DNS* cache for host names if ``True``. @@ -541,13 +541,13 @@ TCPConnector .. attribute:: resolve - Alias for :attr:`cache_dns`. + Alias for :attr:`dns_cache`. .. deprecated:: 0.17 .. attribute:: cached_hosts - The cache of resolved hosts if :attr:`cache_dns` is enabled. + The cache of resolved hosts if :attr:`dns_cache` is enabled. Read-only :class:`types.MappingProxyType` property. diff --git a/tests/test_connector.py b/tests/test_connector.py index 999ab9877b5..c420870373d 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -461,7 +461,7 @@ def test_tcp_connector_ctor(self): with self.assertWarns(DeprecationWarning): self.assertFalse(conn.resolve) - self.assertFalse(conn.cache_dns) + self.assertFalse(conn.dns_cache) self.assertEqual(conn.family, socket.AF_INET) @@ -790,14 +790,14 @@ def test_ambiguous_ctor_params(self): def test_both_resolve_and_cache_dns(self): conn = aiohttp.TCPConnector(resolve=True, cache_dns=True, loop=self.loop) - self.assertTrue(conn.cache_dns) + self.assertTrue(conn.dns_cache) with self.assertWarns(DeprecationWarning): self.assertTrue(conn.resolve) def test_both_cache_dns_only(self): conn = aiohttp.TCPConnector(cache_dns=True, loop=self.loop) - self.assertTrue(conn.cache_dns) + self.assertTrue(conn.dns_cache) with self.assertWarns(DeprecationWarning): self.assertTrue(conn.resolve) From d5f2ac87231c0bd6b55cd7f849a0262f8fd20123 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 20 Jun 2015 17:37:02 +0300 Subject: [PATCH 9/9] Rename to use_dns_cache --- aiohttp/connector.py | 30 +++++++++++++++--------------- docs/client_reference.rst | 6 +++--- tests/test_connector.py | 17 +++++++++-------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 1902d7af95d..b3266533c20 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -402,7 +402,7 @@ class TCPConnector(BaseConnector): """ def __init__(self, *, verify_ssl=True, fingerprint=None, - resolve=_marker, cache_dns=_marker, + resolve=_marker, use_dns_cache=_marker, family=socket.AF_INET, ssl_context=None, **kwargs): super().__init__(**kwargs) @@ -424,21 +424,21 @@ def __init__(self, *, verify_ssl=True, fingerprint=None, if resolve is not _marker: warnings.warn(("resolve parameter is deprecated, " - "use cache_dns instead"), + "use use_dns_cache instead"), DeprecationWarning, stacklevel=2) - if cache_dns is not _marker and resolve is not _marker: - if cache_dns != resolve: - raise ValueError("cache_dns must agree with resolve") - _cache_dns = cache_dns - elif cache_dns is not _marker: - _cache_dns = cache_dns + if use_dns_cache is not _marker and resolve is not _marker: + if use_dns_cache != resolve: + raise ValueError("use_dns_cache must agree with resolve") + _use_dns_cache = use_dns_cache + elif use_dns_cache is not _marker: + _use_dns_cache = use_dns_cache elif resolve is not _marker: - _cache_dns = resolve + _use_dns_cache = resolve else: - _cache_dns = False + _use_dns_cache = False - self._cache_dns = _cache_dns + self._use_dns_cache = _use_dns_cache self._cached_hosts = {} self._ssl_context = ssl_context self._family = family @@ -486,9 +486,9 @@ def family(self): return self._family @property - def dns_cache(self): + def use_dns_cache(self): """True if local DNS caching is enabled.""" - return self._cache_dns + return self._use_dns_cache @property def cached_hosts(self): @@ -511,7 +511,7 @@ def resolve(self): warnings.warn((".resolve property is deprecated, " "use .dns_cache instead"), DeprecationWarning, stacklevel=2) - return self.dns_cache + return self.use_dns_cache @property def resolved_hosts(self): @@ -533,7 +533,7 @@ def clear_resolved_hosts(self, host=None, port=None): @asyncio.coroutine def _resolve_host(self, host, port): - if self._cache_dns: + if self._use_dns_cache: key = (host, port) if key not in self._cached_hosts: diff --git a/docs/client_reference.rst b/docs/client_reference.rst index 383af4ae1fd..624938e215d 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -464,7 +464,7 @@ BaseConnector TCPConnector ^^^^^^^^^^^^ -.. class:: TCPConnector(*, verify_ssl=True, fingerprint=None, cache_dns=False, \ +.. class:: TCPConnector(*, verify_ssl=True, fingerprint=None, use_dns_cache=False, \ family=socket.AF_INET, \ ssl_context=None, conn_timeout=None, \ keepalive_timeout=30, limit=None, share_cookies=False, \ @@ -492,7 +492,7 @@ TCPConnector .. versionadded:: 0.16 - :param bool cache_dns: use internal cache for DNS lookups, ``False`` + :param bool use_dns_cache: use internal cache for DNS lookups, ``False`` by default. Enabling an option *may* speedup connection @@ -501,7 +501,7 @@ TCPConnector .. versionadded:: 0.17 - :param bool resolve: alias for *cache_dns* parameter. + :param bool resolve: alias for *use_dns_cache* parameter. .. deprecated:: 0.17 diff --git a/tests/test_connector.py b/tests/test_connector.py index c420870373d..2030402c5cb 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -461,7 +461,7 @@ def test_tcp_connector_ctor(self): with self.assertWarns(DeprecationWarning): self.assertFalse(conn.resolve) - self.assertFalse(conn.dns_cache) + self.assertFalse(conn.use_dns_cache) self.assertEqual(conn.family, socket.AF_INET) @@ -785,19 +785,20 @@ def test_connector_cookie_deprecation(self): def test_ambiguous_ctor_params(self): with self.assertRaises(ValueError): - aiohttp.TCPConnector(resolve=True, cache_dns=False, loop=self.loop) + aiohttp.TCPConnector(resolve=True, use_dns_cache=False, + loop=self.loop) - def test_both_resolve_and_cache_dns(self): - conn = aiohttp.TCPConnector(resolve=True, cache_dns=True, + def test_both_resolve_and_use_dns_cache(self): + conn = aiohttp.TCPConnector(resolve=True, use_dns_cache=True, loop=self.loop) - self.assertTrue(conn.dns_cache) + self.assertTrue(conn.use_dns_cache) with self.assertWarns(DeprecationWarning): self.assertTrue(conn.resolve) - def test_both_cache_dns_only(self): - conn = aiohttp.TCPConnector(cache_dns=True, + def test_both_use_dns_cache_only(self): + conn = aiohttp.TCPConnector(use_dns_cache=True, loop=self.loop) - self.assertTrue(conn.dns_cache) + self.assertTrue(conn.use_dns_cache) with self.assertWarns(DeprecationWarning): self.assertTrue(conn.resolve)