From 3961e1aec3cc089dc5b5ba73a1fc5646abf36914 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Wed, 4 Jun 2014 19:31:55 -0400 Subject: [PATCH] test_dns: more error handling --- tests/test_dns.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_dns.py b/tests/test_dns.py index 205da6a2..d762a83e 100755 --- a/tests/test_dns.py +++ b/tests/test_dns.py @@ -49,8 +49,13 @@ def test2(tests, server, description): # do the query and format the result as a string try: response = dns.resolver.query(qname, rtype) - except dns.resolver.NXDOMAIN: + except dns.resolver.NoNameservers: # host did not have an answer for this query + print("Could not connect to %s for DNS query." % server) + sys.exit(1) + except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer): + # host did not have an answer for this query; not sure what the + # difference is between the two exceptions response = ["[no value]"] response = ";".join(str(r) for r in response) response = re.sub(r"(\"p=).*(\")", r"\1__KEY__\2", response) # normalize DKIM key