'L{ThreadedResolver.getHostByName} returns a L{Deferred} which fires a
L{Failure} if the call to L{socket.gethostbyname} raises an exception.'

def test_failure(self):

    timeout = 30
    reactor = FakeReactor()
    self.addCleanup(reactor._stop)
    def fakeGetHostByName(name):
        raise IOError('ENOBUFS    (this    is    a    funny    joke)')
    self.patch(socket, 'gethostbyname', fakeGetHostByName)
    failedWith = []
    resolver = ThreadedResolver(reactor)
    d = resolver.getHostByName('some.name', (timeout,))
    self.assertFailure(d, DNSLookupError)
    d.addCallback(failedWith.append)
    reactor._runThreadCalls()
    self.assertEqual(len(failedWith), 1)
    reactor._clock.advance((timeout + 1))
    self.assertEqual(reactor._clock.calls, [])
