'If L{socket.gethostbyname} does not complete before the specified
timeout elapsed, the L{Deferred} returned by
L{ThreadedResolver.getHostByName} fails with L{DNSLookupError}.'

def test_timeout(self):

    timeout = 10
    reactor = FakeReactor()
    self.addCleanup(reactor._stop)
    result = Queue()
    def fakeGetHostByName(name):
        raise result.get()
    self.patch(socket, 'gethostbyname', fakeGetHostByName)
    failedWith = []
    resolver = ThreadedResolver(reactor)
    d = resolver.getHostByName('some.name', (timeout,))
    self.assertFailure(d, DNSLookupError)
    d.addCallback(failedWith.append)
    reactor._clock.advance((timeout - 1))
    self.assertEqual(failedWith, [])
    reactor._clock.advance(1)
    self.assertEqual(len(failedWith), 1)
    result.put(IOError('The    I/O    was    errorful'))
