Don't error out on dnsplug tests is DNS/dns isn't installed as preparation for adding async/aiodns support

This commit is contained in:
Scott Kitterman
2019-11-01 17:24:16 -04:00
parent fa93e56fa2
commit 2dc071962d
+10 -3
View File
@@ -16,18 +16,25 @@
#
# Copyright (c) 2017 Valimail Inc
# Contact: Gene Shuman <gene@valimail.com>
#
# Copyright (c) 2019 Scott Kitterman <scott@kitterman.com>
import unittest
import dkim.dnsplug
import sys
try:
import dkim.dnsplug
except ImportError:
# Need to not error out so we can test aiodns properly
pass
class TestDNSPlug(unittest.TestCase):
def test_get_txt(self):
try:
dkim.dnsplug._get_txt = {"in": "out"}.get
res = dkim.dnsplug.get_txt(b"in")
except NameError: # We may be testing aiodns, so we don't care
res = b"out"
self.assertEqual(res, b"out")