fixed \n escape issue in import

updated test

updated test
This commit is contained in:
Ahtisham Shahid
2020-03-26 14:44:04 +05:00
parent ccbd353201
commit f264e5dd03
2 changed files with 5 additions and 5 deletions

View File

@@ -1059,7 +1059,8 @@ class TestCourseExportImportProblem(CourseTestCase):
category='problem',
display_name='Test Problem',
publish_item=publish_item,
data='<problem><pre><code>x=10</code></pre><multiplechoiceresponse></multiplechoiceresponse></problem>',
data='<problem><pre><code>x=10 print("hello \n")</code></pre>'
'<multiplechoiceresponse></multiplechoiceresponse></problem>',
)
def get_problem_content(self, block_location):
@@ -1075,10 +1076,9 @@ class TestCourseExportImportProblem(CourseTestCase):
"""
Asserts that problems' data is as expected with pre-tag content maintained.
"""
expected_problem_content = '<problem>\n <pre><code>x=10</code></pre>\n' \
' <multiplechoiceresponse/>\n</problem>\n'
expected_problem_content = '<problem>\n <pre>\n <code>x=10 print("hello \n")</code>\n </pre>\n ' \
'<multiplechoiceresponse/>\n</problem>\n'
problem_content = self.get_problem_content(course_location)
self.assertEqual(expected_problem_content, problem_content)
def test_problem_content_on_course_export_import(self):

View File

@@ -29,7 +29,7 @@ class RawMixin(object):
data = etree.tostring(xml_object, pretty_print=True, encoding='unicode')
if pre_tag_data:
for index, pre_tag in enumerate(re.findall(PRE_TAG_REGEX, data)):
data = re.sub(re.escape(pre_tag), pre_tag_data[index].decode(), data)
data = re.sub(pre_tag, pre_tag_data[index].decode(), data)
return {'data': data}, []
def definition_to_xml(self, resource_fs):