'The L{DNSDatagramProtocol} created when an interim timeout occurs is
also disconnected from its transport after the Deferred returned by its
query method completes.'

def test_protocolShutDownAfterTimeout(self):

    resolver = client.Resolver(servers=[('example.com', 53)])
    protocols = []
    result = defer.Deferred()
    results = [defer.fail(failure.Failure(DNSQueryTimeoutError(None))), result]
    class FakeProtocol(object, ):
        def __init__(self):
            self.transport = StubPort()
        def query(self, address, query, timeout=10, id=None):
            protocols.append(self)
            return results.pop(0)
    resolver._connectedProtocol = FakeProtocol
    resolver.query(dns.Query('foo.example.com'))
    self.assertFalse(protocols[1].transport.disconnected)
    result.callback(dns.Message())
    self.assertTrue(protocols[1].transport.disconnected)
