'Try a RETR, but disconnect during the transfer.
L{ftp.FTPClient.retrieveFile} should return a Deferred which
errbacks with L{ftp.ConnectionLost)'

def test_lostRETR(self):

    self.client.passive = False
    l = []
    def generatePort(portCmd):
        portCmd.text = ('PORT    %s' % (ftp.encodeHostPort('127.0.0.1', 9876),))
        tr = proto_helpers.StringTransportWithDisconnection()
        portCmd.protocol.makeConnection(tr)
        tr.protocol = portCmd.protocol
        portCmd.protocol.dataReceived(('x' * 500))
        l.append(tr)
    self.client.generatePortCommand = generatePort
    self._testLogin()
    proto = _BufferingProtocol()
    d = self.client.retrieveFile('spam', proto)
    self.assertEqual(self.transport.value(), ('PORT    %s\r\n' % (ftp.encodeHostPort('127.0.0.1', 9876),)).encode(self.client._encoding))
    self.transport.clear()
    self.client.lineReceived('200    PORT    OK')
    self.assertEqual(self.transport.value(), 'RETR    spam\r\n')
    self.assertTrue(l)
    l[0].loseConnection()
    self.transport.loseConnection()
    self.assertFailure(d, ftp.ConnectionLost)
    return d
