From: Bob Halley Date: Thu, 21 May 2020 14:43:55 +0000 (-0700) Subject: do not run DoH tests if there is no network X-Git-Tag: v2.0.0rc1~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6405207dbf13b53cee87ceffd6ff6e05ef257007;p=thirdparty%2Fdnspython.git do not run DoH tests if there is no network --- diff --git a/tests/test_doh.py b/tests/test_doh.py index 51f32ae6..48fa47ea 100644 --- a/tests/test_doh.py +++ b/tests/test_doh.py @@ -16,6 +16,7 @@ # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. import unittest import random +import socket import dns.query import dns.rdatatype @@ -30,7 +31,15 @@ KNOWN_ANYCAST_DOH_RESOLVER_URLS = ['https://cloudflare-dns.com/dns-query', 'https://dns.google/dns-query', 'https://dns11.quad9.net/dns-query'] -@unittest.skipUnless(dns.query.have_doh, +# 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 + +@unittest.skipUnless(dns.query.have_doh and _network_available, "Python requests cannot be imported; no DNS over HTTPS (DOH)") class DNSOverHTTPSTestCase(unittest.TestCase): def setUp(self):