def test_LIST(self):
        """
        Test the LIST command in non-passive mode.

        Like L{test_passiveLIST} 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())
            self.client.lineReceived(
                b'150 File status okay; about to open data connection.')
            sending = [
                b'-rw-r--r--    0 spam      egg      100 Oct 10 2006 foo\r\n',
                b'-rw-r--r--    3 spam      egg      100 Oct 10 2006 bar\r\n',
                b'-rw-r--r--    4 spam      egg      100 Oct 10 2006 baz\r\n',
            ]
            for i in sending:
                portCmd.protocol.dataReceived(i)
            portCmd.protocol.connectionLost(
                failure.Failure(error.ConnectionDone("")))

        def cbList(res, fileList):
            fls = [f["filename"] for f in fileList.files]
            expected = ["foo", "bar", "baz"]
            expected.sort()
            fls.sort()
            self.assertEqual(fls, expected)

        self.client.generatePortCommand = generatePort
        self._testLogin()
        fileList = ftp.FTPFileListProtocol()
        d = self.client.list('foo/bar', fileList).addCallback(cbList, fileList)
        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'LIST foo/bar\r\n')
        self.transport.clear()
        self.client.lineReceived(b'226 Transfer Complete.')
        return d

        Test the LIST command in non-passive mode.

        Like L{test_passiveLIST} 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