'If a connection attempt initiated by
L{HostnameEndpoint.connect} succeeds only after
L{HostnameEndpoint} has exhausted the list of possible server
addresses, the returned L{Deferred} will fire with the
connected protocol instance and the endpoint will leave no
delayed calls in the reactor.'

def test_endpointConnectSuccessAfterIteration(self):

    proto = object()
    mreactor = MemoryReactor()
    clientFactory = object()
    (ep, expectedArgs, ignoredDest) = self.createClientEndpoint(mreactor, clientFactory)
    d = ep.connect(clientFactory)
    receivedProtos = []
    def checkProto(p):
        receivedProtos.append(p)
    d.addCallback(checkProto)
    factory = self.retrieveConnectedFactory(mreactor)
    mreactor.advance(0.3)
    factory._onConnection.callback(proto)
    self.assertEqual(receivedProtos, [proto])
    expectedClients = self.expectedClients(mreactor)
    self.assertEqual(len(expectedClients), 1)
    self.assertConnectArgs(expectedClients[0], expectedArgs)
    self.assertEqual([], mreactor.getDelayedCalls())
