def run_mgmt_command(capsys):
    """Function fixture that runs a python manage.py with arguments
    and returns the stdout and stderr as a tuple.
    """

    def f(cmd_class, argv=None):
        argv = argv or []
        cmd = cmd_class()
        cmd.run_from_argv(["manage.py"] + argv)
        out, err = capsys.readouterr()
        return out, err

    return f