def prints(monkeypatch):
    """Capture prints into a list."""
    prints = []
    def save_print(*args, **kw):
        prints.append((args, kw))

    if hasattr(__builtins__, 'get'):
        monkeypatch.setitem(__builtins__, 'print', save_print)
    else:
        # For pypy we need to monkeypatch differently.
        monkeypatch.setattr(__builtins__, 'print', save_print)

    return prints