'Run a task and trigger an artificial failure with the given message.'

def _test_run_with_failure(self, task_class, expected_message):

    task_entry = self._create_input_entry()
    self.define_option_problem(PROBLEM_URL_NAME)
    with self.assertRaises(TestTaskFailure):
        self._run_task_with_mock_celery(task_class, task_entry.id, task_entry.task_id, expected_message)
    entry = InstructorTask.objects.get(id=task_entry.id)
    self.assertEquals(entry.task_state, FAILURE)
    output = json.loads(entry.task_output)
    self.assertEquals(output['exception'], 'TestTaskFailure')
    self.assertEquals(output['message'], expected_message)
