'Test that celery handles bad address errors by failing and not retrying.'

def _test_email_address_failures(self, exception):

    num_emails = settings.BULK_EMAIL_EMAILS_PER_TASK
    self._create_students((num_emails - 1))
    expected_fails = int(((num_emails + 3) / 4.0))
    expected_succeeds = (num_emails - expected_fails)
    with patch('bulk_email.tasks.get_connection', autospec=True) as get_conn:
        get_conn.return_value.send_messages.side_effect = cycle([exception, None, None, None])
        self._test_run_with_task(send_bulk_course_email, 'emailed', num_emails, expected_succeeds, failed=expected_fails)
