def test_STOR(self):
        """
        Test the STOR command in non-passive mode.

        Like L{test_passiveSTOR} but in the configuration where the server
        establishes the data connection to the client, rather than the other
        way around.
        """
        tr = proto_helpers.StringTransport()
        self.client.passive = False
        def generatePort(portCmd):
            portCmd.text = 'PORT ' + ftp.encodeHostPort('127.0.0.1', 9876)
            portCmd.protocol.makeConnection(tr)

        def cbStore(sender):
            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'STOR spam\r\n')
            self.transport.clear()
            self.client.lineReceived(
                b'150 File status okay; about to open data connection.')
            sender.transport.write(b"x" * 1000)
            sender.finish()
            sender.connectionLost(failure.Failure(error.ConnectionDone("")))
            self.client.lineReceived(b'226 Transfer Complete.')

        def cbFinish(ign):
            self.assertEqual(tr.value(), b"x" * 1000)

        self.client.generatePortCommand = generatePort
        self._testLogin()
        d1, d2 = self.client.storeFile("spam")
        d1.addCallback(cbStore)
        d2.addCallback(cbFinish)
        return defer.gatherResults([d1, d2])

        Test the STOR command in non-passive mode.

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