def test_STORtransferErrorIsReturned(self):
        """
        Any FTP error raised by STOR while transferring the file is returned
        to the client.
        """
        # Make a failing file writer.
        class FailingFileWriter(ftp._FileWriter):
            def receive(self):
                return defer.fail(ftp.IsADirectoryError("failing_file"))

        def failingSTOR(a, b):
            return defer.succeed(FailingFileWriter(None))

        # Monkey patch the shell so it returns a file writer that will
        # fail during transfer.
        self.patch(ftp.FTPAnonymousShell, 'openForWriting', failingSTOR)

        def eb(res):
            res.trap(ftp.CommandFailed)
            logs = self.flushLoggedErrors()
            self.assertEqual(1, len(logs))
            self.assertIsInstance(logs[0].value, ftp.IsADirectoryError)
            self.assertEqual(
                res.value.args[0][0],
                "550 failing_file: is a directory")
        d1, d2 = self.client.storeFile('failing_file')
        d2.addErrback(eb)
        return defer.gatherResults([d1, d2])

        Any FTP error raised by STOR while transferring the file is returned
        to the client.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp.py