def test_recursiveConfiguration(self): """ Recursive DNS lookups, if enabled, should be a last-resort option. Any other lookup method (cache, local lookup, etc.) should take precedence over recursive lookups """ options = Options() options.parseOptions(['--hosts-file', 'hosts.txt', '--recursive']) ca, cl = _buildResolvers(options) # Extra cleanup, necessary on POSIX because client.Resolver doesn't know # when to stop parsing resolv.conf. See #NNN for improving this. for x in cl: if isinstance(x, ResolverChain): recurser = x.resolvers[-1] if isinstance(recurser, Resolver): recurser._parseCall.cancel() # On Windows, we need to use a threaded resolver, which leaves trash # lying about that we can't easily clean up without reaching into the # reactor and cancelling them. We only cancel the cleanup functions, as # there should be no others (and it leaving a callLater lying about # should rightly cause the test to fail). if platform.getType() != 'posix': # We want the delayed calls on the reactor, which should be all of # ours from the threaded resolver cleanup from twisted.internet import reactor for x in reactor._newTimedCalls: self.assertEqual(x.func.__func__, ThreadedResolver._cleanup) x.cancel() self.assertIsInstance(cl[-1], ResolverChain)
def test_recursiveConfiguration(self): """ Recursive DNS lookups, if enabled, should be a last-resort option. Any other lookup method (cache, local lookup, etc.) should take precedence over recursive lookups """ options = Options() options.parseOptions(['--hosts-file', 'hosts.txt', '--recursive']) ca, cl = _buildResolvers(options) # Extra cleanup, necessary on POSIX because client.Resolver doesn't know # when to stop parsing resolv.conf. See #NNN for improving this. for x in cl: if isinstance(x, ResolverChain): recurser = x.resolvers[-1] if isinstance(recurser, Resolver): recurser._parseCall.cancel() self.assertIsInstance(cl[-1], ResolverChain)
def test_recursiveConfiguration(self): """ Recursive DNS lookups, if enabled, should be a last-resort option. Any other lookup method (cache, local lookup, etc.) should take precedence over recursive lookups """ options = Options() options.parseOptions(['--hosts-file', 'hosts.txt', '--recursive']) ca, cl = _buildResolvers(options) # Extra cleanup, necessary on POSIX because client.Resolver doesn't know # when to stop parsing resolv.conf. See #NNN for improving this. for x in cl: if isinstance(x, ResolverChain): recurser = x.resolvers[-1] if isinstance(recurser, Resolver): recurser._parseCall.cancel() # On Windows, we need to use a threaded resolver, which leaves trash # lying about that we can't easily clean up without reaching into the # reactor and cancelling them. We only cancel the cleanup functions, as # there should be no others (and it leaving a callLater lying about # should rightly cause the test to fail). if platform.getType() != 'posix': # We want the delayed calls on the reactor, which should be all of # ours from the threaded resolver cleanup from twisted.internet import reactor for x in reactor._newTimedCalls: if _PY3: self.assertEqual(x.func.__func__, ThreadedResolver._cleanup) else: self.assertEqual(x.func.__func__, ThreadedResolver._cleanup.__func__) x.cancel() self.assertIsInstance(cl[-1], ResolverChain)