diff --git a/xmodule/tests/test_word_cloud.py b/xmodule/tests/test_word_cloud.py index a550734bb67..3b965284a97 100644 --- a/xmodule/tests/test_word_cloud.py +++ b/xmodule/tests/test_word_cloud.py @@ -2,9 +2,7 @@ import json import os -from io import BytesIO from unittest.mock import Mock -from lxml.etree import ElementTree from django.test import TestCase from fs.memoryfs import MemoryFS @@ -40,7 +38,7 @@ def test_xml_import_export_cycle(self): runtime.export_fs = MemoryFS() original_xml = ( - '\n' ) @@ -61,17 +59,17 @@ def test_xml_import_export_cycle(self): filepath = 'word_cloud/block_id.xml' runtime.export_fs.makedirs(os.path.dirname(filepath), recreate=True) - # exported_xml_buffer = BytesIO() with runtime.export_fs.open(filepath, 'wb') as fileobj: - # ElementTree(xml_object).write(fileobj, pretty_print=True, encoding='utf-8') runtime.export_to_xml(block, fileobj) with runtime.export_fs.open('word_cloud/block_id.xml') as f: exported_xml = f.read() - # FIXME: Fix this case - # assert original_xml == exported_xml - # assert exported_xml_buffer.getvalue() == original_xml + exported_xml_tree = etree.fromstring(exported_xml.encode('utf-8')) + etree.cleanup_namespaces(etree.fromstring(exported_xml.encode('utf-8'))) + exported_xml = etree.tostring(exported_xml_tree, encoding='unicode', pretty_print=True) + + assert original_xml == exported_xml def test_bad_ajax_request(self): """ @@ -123,7 +121,7 @@ def test_indexibility(self): module_system = get_test_system() block = WordCloudBlock(module_system, DictFieldData(self.raw_field_data), Mock()) - assert block.index_dictionary() ==\ + assert block.index_dictionary() == \ {'content_type': 'Word Cloud', 'content': {'display_name': 'Word Cloud Block', 'instructions': 'Enter some random words that comes to your mind'}}