@contextmanager<EOL>def redirect_stdout(new_stdout):
old_stdout, sys.stdout = sys.stdout, new_stdout<EOL>try:<EOL><INDENT>yield None<EOL><DEDENT>finally:<EOL><INDENT>sys.stdout = old_stdout<EOL><DEDENT>
Redirect the stdout

    Args:
        new_stdout (io.StringIO): New stdout to use instead