@contextmanager
def _capture_output():
    (oldout, olderr) = (sys.stdout, sys.stderr)
    try:
        out = [StringIO(), StringIO()]
        (sys.stdout, sys.stderr) = out
        (yield out)
    finally:
        (sys.stdout, sys.stderr) = (oldout, olderr)
        out[0] = out[0].getvalue()
        out[1] = out[1].getvalue()
@contextmanager
def _capture_output():
    (oldout, olderr) = (sys.stdout, sys.stderr)
    try:
        out = [StringIO(), StringIO()]
        (sys.stdout, sys.stderr) = out
        (yield out)
    finally:
        (sys.stdout, sys.stderr) = (oldout, olderr)
        out[0] = out[0].getvalue()
        out[1] = out[1].getvalue()