Fix test_import and unicode issues.

Handle unicode in get_course_index
This commit is contained in:
Diana Huang
2014-07-08 10:42:22 -04:00
parent 638a1aaec4
commit c21977326c
4 changed files with 4 additions and 4 deletions

View File

@@ -99,7 +99,7 @@ class ErrorDescriptor(ErrorFields, XModuleDescriptor):
# real metadata stays in the content, but add a display name
field_data = DictFieldData({
'error_msg': str(error_msg),
'error_msg': unicode(error_msg),
'contents': contents,
'location': location,
'category': 'error'

View File

@@ -80,7 +80,7 @@ class MongoConnection(object):
"""
Get the course_index from the persistence mechanism whose id is the given key
"""
case_regex = r"(?i)^{}$" if ignore_case else r"{}"
case_regex = ur"(?i)^{}$" if ignore_case else ur"{}"
return self.course_index.find_one(
son.SON([
(key_attr, re.compile(case_regex.format(getattr(key, key_attr))))

View File

@@ -438,7 +438,7 @@ class ImportTestCase(BaseCourseTestCase):
print("course errors:")
# Expect to find an error/exception about characters in "®esources"
expect = "UnicodeEncodeError"
expect = "InvalidKeyError"
errors = [
(msg.encode("utf-8"), err.encode("utf-8"))
for msg, err

View File

@@ -605,7 +605,7 @@ def policy_key(location):
Get the key for a location in a policy file. (Since the policy file is
specific to a course, it doesn't need the full location url).
"""
return '{cat}/{name}'.format(cat=location.category, name=location.name)
return u'{cat}/{name}'.format(cat=location.category, name=location.name)
Template = namedtuple("Template", "metadata data children")