'If an endpoint tries to connect to a non-listening port it gets
a C{ConnectError} failure.'

def test_endpointConnectFailure(self):

    expectedError = error.ConnectError(string='Connection    Failed')
    mreactor = RaisingMemoryReactorWithClock(connectException=expectedError)
    clientFactory = object()
    (ep, ignoredArgs, ignoredDest) = self.createClientEndpoint(mreactor, clientFactory)
    d = ep.connect(clientFactory)
    mreactor.advance(0.3)
    self.assertEqual(self.failureResultOf(d).value, expectedError)
    self.assertEqual([], mreactor.getDelayedCalls())
