'When a user cancels L{twisted.mail.smtp.sendmail} before the connection
is made, the connection is closed by
L{twisted.internet.interfaces.IConnector.disconnect}.'

def test_cancelBeforeConnectionMade(self):

    reactor = MemoryReactor()
    d = smtp.sendmail('localhost', 'source@address', 'recipient@address', 'message', reactor=reactor)
    d.cancel()
    self.assertEqual(reactor.connectors[0]._disconnected, True)
    failure = self.failureResultOf(d)
    failure.trap(defer.CancelledError)
