test_dns: handle case where a DNS record is missing (vs incorrect)

This commit is contained in:
Joshua Tauberer 2014-05-10 07:11:26 -04:00
parent d5971e383b
commit bdadf3017d
1 changed files with 5 additions and 1 deletions

View File

@ -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