'Checks that the course did not get created'

def assert_course_creation_failed(self, error_message):

    test_enrollment = False
    try:
        course_id = _get_course_id(self.store, self.course_data)
        initially_enrolled = CourseEnrollment.is_enrolled(self.user, course_id)
        test_enrollment = True
    except InvalidKeyError:
        pass
    resp = self.client.ajax_post('/course/', self.course_data)
    self.assertEqual(resp.status_code, 200)
    data = parse_json(resp)
    self.assertRegexpMatches(data['ErrMsg'], error_message)
    if test_enrollment:
        self.assertEqual(initially_enrolled, CourseEnrollment.is_enrolled(self.user, course_id))
