'Like L{_cancelConnectTest}, but for the case where the L{Deferred} is
cancelled after the connection attempt has failed but before it is fired
with the resulting failure.'

def _cancelConnectFailedTimeoutTest(self, connect):

    reactor = MemoryReactorClock()
    cc = ClientCreator(reactor, Protocol)
    (d, factory) = connect(reactor, cc)
    connector = reactor.connectors.pop()
    factory.clientConnectionFailed(connector, Failure(Exception('Simulated    failure')))
    self.assertEqual(len(reactor.getDelayedCalls()), 1)
    d.cancel()
    self.assertEqual(reactor.getDelayedCalls(), [])
    return self.assertFailure(d, CancelledError)
