]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
apply v4/v6 testing scheme from query tests to async too 815/head
authorBob Halley <halley@dnspython.org>
Sat, 11 Jun 2022 02:49:53 +0000 (19:49 -0700)
committerBob Halley <halley@dnspython.org>
Sat, 11 Jun 2022 02:49:53 +0000 (19:49 -0700)
tests/test_async.py

index 21758d9ec2928b5053112b2534eb1295d1f2208a..f40146e216a6a7197e607a953b507d53ab1a2665 100644 (file)
@@ -53,20 +53,11 @@ try:
 except Exception:
     pass
 
-# Probe for IPv4 and IPv6
 query_addresses = []
-for (af, address) in (
-    (socket.AF_INET, "8.8.8.8"),
-    (socket.AF_INET6, "2001:4860:4860::8888"),
-):
-    try:
-        with socket.socket(af, socket.SOCK_DGRAM) as s:
-            # Connecting a UDP socket is supposed to return ENETUNREACH if
-            # no route to the network is present.
-            s.connect((address, 53))
-        query_addresses.append(address)
-    except Exception:
-        pass
+if tests.util.have_ipv4():
+    query_addresses.append("8.8.8.8")
+if tests.util.have_ipv6():
+    query_addresses.append("2001:4860:4860::8888")
 
 KNOWN_ANYCAST_DOH_RESOLVER_URLS = [
     "https://cloudflare-dns.com/dns-query",