def test_RETR(self):
        """
        Test the RETR command in non-passive mode.

        Like L{test_passiveRETR} but in the configuration where the server
        establishes the data connection to the client, rather than the other
        way around.
        """
        self.client.passive = False

        def generatePort(portCmd):
            portCmd.text = 'PORT %s' % (ftp.encodeHostPort('127.0.0.1', 9876),)
            portCmd.protocol.makeConnection(proto_helpers.StringTransport())
            portCmd.protocol.dataReceived(b"x" * 1000)
            portCmd.protocol.connectionLost(
                failure.Failure(error.ConnectionDone("")))

        def cbRetr(res, proto):
            self.assertEqual(proto.buffer, b'x' * 1000)

        self.client.generatePortCommand = generatePort
        self._testLogin()
        proto = _BufferingProtocol()
        d = self.client.retrieveFile("spam", proto)
        d.addCallback(cbRetr, 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(b'200 PORT OK')
        self.assertEqual(self.transport.value(), b'RETR spam\r\n')
        self.transport.clear()
        self.client.lineReceived(b'226 Transfer Complete.')
        return d

        Test the RETR command in non-passive mode.

        Like L{test_passiveRETR} but in the configuration where the server
        establishes the data connection to the client, rather than the other
        way around.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp.py