self.nameservers.append(ns)
def _config_win32_domain(self, domain): # pragma: no cover
+ # Sometimes DHCP servers add a '.' prefix to the default domain, and
+ # Windows just stores such values in the registry (see #687).
+ # Check for this and fix it.
+ if domain.startswith('.'):
+ domain = domain[1:]
# we call str() on domain to convert it from unicode to ascii
self.domain = dns.name.from_text(str(domain))
# not raising is the test
res._compute_timeout(now + 0.5)
+ def test_configure_win32_domain(self):
+ # This is a win32-related test but it works on all platforms so we
+ # test it that way to make coverage analysis easier.
+ n = dns.name.from_text('home.')
+ res = dns.resolver.Resolver(configure=False)
+ res._config_win32_domain('home')
+ self.assertEqual(res.domain, n)
+ res._config_win32_domain('.home')
+ self.assertEqual(res.domain, n)
+
class ResolverNameserverValidTypeTestCase(unittest.TestCase):
def test_set_nameservers_to_list(self):