from io import StringIO
import contextlib


def eat_output(f):
    """This decorators directs standard output and standard error to a memory buffer
    """

    def decorated(*args, **kwargs):
        buffer = StringIO()
        with contextlib.redirect_stdout(buffer):
            with contextlib.redirect_stderr(buffer):
                return f(*args, **kwargs)

    return decorated