'Test that celery can hit a maximum number of retries.'

def _test_max_retry_limit_causes_failure(self, exception):

    num_emails = 10
    self._create_students((num_emails - 1))
    expected_fails = num_emails
    expected_succeeds = 0
    with patch('bulk_email.tasks.get_connection', autospec=True) as get_conn:
        get_conn.return_value.send_messages.side_effect = cycle([exception])
        with patch('bulk_email.tasks.update_subtask_status', my_update_subtask_status):
            self._test_run_with_task(send_bulk_course_email, 'emailed', num_emails, expected_succeeds, failed=expected_fails, retried_withmax=(settings.BULK_EMAIL_MAX_RETRIES + 1))
