from nose.tools import istest, assert_equal from .testing import test_path import mammoth @istest def docx_containing_one_paragraph_is_converted_to_single_p_element(): with open(test_path("single-paragraph.docx"), "rb") as fileobj: result = mammoth.convert_to_html(fileobj=fileobj) assert_equal("

Walking on imported air

", result.value) assert_equal([], result.messages) @istest def inline_images_are_included_in_output(): with open(test_path("tiny-picture.docx"), "rb") as fileobj: result = mammoth.convert_to_html(fileobj=fileobj) assert_equal("""

""", result.value) assert_equal([], result.messages) @istest def simple_list_is_converted_to_list_elements(): with open(test_path("simple-list.docx"), "rb") as fileobj: result = mammoth.convert_to_html(fileobj=fileobj) assert_equal([], result.messages) assert_equal("", result.value) @istest def transform_document_is_applied_to_document_before_conversion(): def transform_document(document): document.children[0].style_id = "Heading1" return document with open(test_path("single-paragraph.docx"), "rb") as fileobj: result = mammoth.convert_to_html(fileobj=fileobj, transform_document=transform_document) assert_equal("

Walking on imported air

", result.value) assert_equal([], result.messages)