def test_addWriter(self):
        reactor = self.buildReactor()

        class DisconnectProtocol(Protocol):
            def connectionLost(self, reason):
                reactor.stop()

        path = self.mktemp()

        with open(path, "wb") as f:
            # Write bytes to a transport, hopefully have them written to a
            # file:
            protocol = DisconnectProtocol()
            StandardIO(protocol, stdout=f.fileno(),
                       stdin=self.extraFile.fileno(), reactor=reactor)
            protocol.transport.write(b"hello")
            protocol.transport.write(b", world")
            protocol.transport.loseConnection()

            self.runReactor(reactor)

        with open(path, "rb") as f:
            self.assertEqual(f.read(), b"hello, world")
Adding a filesystem file writer to a reactor will make sure it is
dataset/ETHPy150Open twisted/twisted/twisted/internet/test/test_stdio.py/StdioFilesTests.test_addWriter