def test_write(self):
        """
        Test L{ftp.IWriteFile}: the implementation should have a receive
        method returning a C{Deferred} which fires with a consumer ready to
        receive data to be written. It should also have a close() method that
        returns a Deferred.
        """
        content = b'elbbow\n'
        def cbGet(writer):
            return writer.receive().addCallback(cbReceive, writer)
        def cbReceive(consumer, writer):
            producer = TestProducer(content, consumer)
            consumer.registerProducer(None, True)
            producer.start()
            consumer.unregisterProducer()
            return writer.close().addCallback(cbClose)
        def cbClose(ignored):
            self.assertEqual(self.getFileContent(), content)
        return self.getFileWriter().addCallback(cbGet)

        Test L{ftp.IWriteFile}: the implementation should have a receive
        method returning a C{Deferred} which fires with a consumer ready to
        receive data to be written. It should also have a close() method that
        returns a Deferred.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp.py