From f264e5dd035f5e6719939612e49c4d9eaf3f3d4a Mon Sep 17 00:00:00 2001 From: Ahtisham Shahid Date: Thu, 26 Mar 2020 14:44:04 +0500 Subject: [PATCH] fixed \n escape issue in import updated test updated test --- .../contentstore/views/tests/test_import_export.py | 8 ++++---- common/lib/xmodule/xmodule/raw_module.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cms/djangoapps/contentstore/views/tests/test_import_export.py b/cms/djangoapps/contentstore/views/tests/test_import_export.py index 6fe8fda67b..cdbc4a0dec 100644 --- a/cms/djangoapps/contentstore/views/tests/test_import_export.py +++ b/cms/djangoapps/contentstore/views/tests/test_import_export.py @@ -1059,7 +1059,8 @@ class TestCourseExportImportProblem(CourseTestCase): category='problem', display_name='Test Problem', publish_item=publish_item, - data='
x=10
', + data='
x=10 print("hello \n")
' + '
', ) 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 = '\n
x=10
\n' \ - ' \n
\n' + expected_problem_content = '\n
\n    x=10 print("hello \n")\n  
\n ' \ + '\n
\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): diff --git a/common/lib/xmodule/xmodule/raw_module.py b/common/lib/xmodule/xmodule/raw_module.py index 02ab2181a0..4d80245357 100644 --- a/common/lib/xmodule/xmodule/raw_module.py +++ b/common/lib/xmodule/xmodule/raw_module.py @@ -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):