diff --git a/cms/djangoapps/contentstore/views/tests/test_import_export.py b/cms/djangoapps/contentstore/views/tests/test_import_export.py
index a7b23ab19b..dd63e8cda1 100644
--- a/cms/djangoapps/contentstore/views/tests/test_import_export.py
+++ b/cms/djangoapps/contentstore/views/tests/test_import_export.py
@@ -1021,3 +1021,93 @@ class TestCourseExportImport(LibraryTestCase):
dest_course.location,
publish_item
)
+
+
+@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
+class TestCourseExportImportProblem(CourseTestCase):
+ """
+ Tests for importing after exporting the course containing problem with pre tags from XML.
+ """
+ def setUp(self):
+ super(TestCourseExportImportProblem, self).setUp()
+ self.export_dir = tempfile.mkdtemp()
+ self.source_course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split)
+ self.addCleanup(shutil.rmtree, self.export_dir, ignore_errors=True)
+
+ def _setup_source_course_with_problem_content(self, publish_item=False):
+ """
+ Sets up course with problem content.
+ """
+ chapter = ItemFactory.create(
+ parent_location=self.source_course.location,
+ category='chapter',
+ display_name='Test Section'
+ )
+ sequential = ItemFactory.create(
+ parent_location=chapter.location,
+ category='sequential',
+ display_name='Test Sequential'
+ )
+ vertical = ItemFactory.create(
+ category='vertical',
+ parent_location=sequential.location,
+ display_name='Test Unit'
+ )
+
+ ItemFactory.create(
+ parent=vertical,
+ category='problem',
+ display_name='Test Problem',
+ publish_item=publish_item,
+ data='x=10
\n' \
+ ' x=10
[\s\S]*?') + class RawMixin(object): """ @@ -22,7 +25,12 @@ class RawMixin(object): @classmethod def definition_from_xml(cls, xml_object, system): - return {'data': etree.tostring(xml_object, pretty_print=True, encoding='unicode')}, [] + pre_tag_data = [etree.tostring(pre_tag_info) for pre_tag_info in xml_object.findall('pre')] + 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) + return {'data': data}, [] def definition_to_xml(self, resource_fs): """