def test_beginLoggingToRedirectStandardIO(self):
        """
        L{LogBeginner.beginLoggingTo} will re-direct the standard output and
        error streams by setting the C{stdio} and C{stderr} attributes on its
        sys module object.
        """
        x = []
        self.beginner.beginLoggingTo([x.append])
        print("Hello, world.", file=self.sysModule.stdout)
        compareEvents(
            self, x, [dict(log_namespace="stdout", log_io="Hello, world.")]
        )
        del x[:]
        print("Error, world.", file=self.sysModule.stderr)
        compareEvents(
            self, x, [dict(log_namespace="stderr", log_io="Error, world.")]
        )

        L{LogBeginner.beginLoggingTo} will re-direct the standard output and
        error streams by setting the C{stdio} and C{stderr} attributes on its
        sys module object.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/logger/test/test_global.py