from unittest.mock import call


def run_management_cmd_for(project_name, testcmd_args, *command_args):
    """
    Execute a management command, including the required settings if needed.
    """
    manage_cmd = ['python', 'manage.py'] + list(command_args)
    if 'multi' in testcmd_args:
        manage_cmd += ['--settings', '%s.settings' % project_name]
    return call(manage_cmd)