From bdadf3017d682f48c54ee717ac26a9dcd8192eb1 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sat, 10 May 2014 07:11:26 -0400 Subject: [PATCH] test_dns: handle case where a DNS record is missing (vs incorrect) --- tests/test_dns.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_dns.py b/tests/test_dns.py index c107dfc..cb7aa0f 100755 --- a/tests/test_dns.py +++ b/tests/test_dns.py @@ -42,7 +42,11 @@ def test2(tests, server, description): resolver.nameservers = [server] for qname, rtype, expected_answer in tests: # do the query and format the result as a string - response = dns.resolver.query(qname, rtype) + try: + response = dns.resolver.query(qname, rtype) + except dns.resolver.NXDOMAIN: + # host did not have an answer for this query + response = ["NOT SET"] response = ";".join(str(r) for r in response) response = re.sub(r"(\"p=).*(\")", r"\1__KEY__\2", response) # normalize DKIM key