summaryrefslogtreecommitdiff
path: root/tests/test_async.py
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@ubuntu.com>2022-05-16 12:39:40 +0200
committerBenjamin Drung <bdrung@ubuntu.com>2022-05-16 12:39:40 +0200
commit0b7f5fe05b157164d0fad543bceb483e07abffde (patch)
tree4172f681734f469cf3d5890c800d887b0b94b3c8 /tests/test_async.py
parent9c07b180032b815369a8bdea7269315d5a238033 (diff)
downloaddnspython-0b7f5fe05b157164d0fad543bceb483e07abffde.tar.gz
Add tests.util.is_internet_reachable()
Introduce `tests.util.is_internet_reachable` to avoid duplicate code. Signed-off-by: Benjamin Drung <bdrung@ubuntu.com>
Diffstat (limited to 'tests/test_async.py')
-rw-r--r--tests/test_async.py13
1 files changed, 2 insertions, 11 deletions
diff --git a/tests/test_async.py b/tests/test_async.py
index 3c9a7e6..21758d9 100644
--- a/tests/test_async.py
+++ b/tests/test_async.py
@@ -31,7 +31,7 @@ import dns.query
import dns.rdataclass
import dns.rdatatype
import dns.resolver
-
+import tests.util
# Some tests require TLS so skip those if it's not there.
ssl = dns.query.ssl
@@ -42,15 +42,6 @@ except Exception:
_ssl_available = False
-# Some tests require the internet to be available to run, so let's
-# skip those if it's not there.
-_network_available = True
-try:
- socket.gethostbyname("dnspython.org")
-except socket.gaierror:
- _network_available = False
-
-
# Look for systemd-resolved, as it does dangling CNAME responses incorrectly.
#
# Currently we simply check if the nameserver is 127.0.0.53.
@@ -178,7 +169,7 @@ class MiscQuery(unittest.TestCase):
self.assertEqual(t, ("::", 53))
-@unittest.skipIf(not _network_available, "Internet not reachable")
+@unittest.skipIf(not tests.util.is_internet_reachable(), "Internet not reachable")
class AsyncTests(unittest.TestCase):
connect_udp = sys.platform == "win32"