aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-03-14 20:46:13 +0000
committerMichael Williamson <mike@zwobble.org>2016-03-14 20:46:13 +0000
commit2c57c1014ae8e44e62021ea2cc36c54352389632 (patch)
tree323783d8b772535dddfd54e1342fce8fe4e4d636 /tests
parentb34f7280c0754f9fc88725358e22ac46d9a2a598 (diff)
Implement collapsing using HTML AST
Diffstat (limited to 'tests')
-rw-r--r--tests/conversion_tests.py6
-rw-r--r--tests/mammoth_tests.py6
2 files changed, 6 insertions, 6 deletions
diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py
index 98359a7..cb6f961 100644
--- a/tests/conversion_tests.py
+++ b/tests/conversion_tests.py
@@ -7,7 +7,7 @@ import io
from nose.tools import istest, assert_equal
import mammoth
-from mammoth import documents, style_reader, results
+from mammoth import documents, style_reader, results, html
from mammoth.conversion import convert_document_element_to_html
from mammoth.docx.xmlparser import parse_xml
@@ -365,9 +365,9 @@ def images_have_alt_tags_if_available():
@istest
def can_define_custom_conversion_for_images():
- def convert_image(image, html_generator):
+ def convert_image(image):
with image.open() as image_file:
- html_generator.self_closing("img", {"alt": image_file.read().decode("ascii")})
+ return [html.self_closing_element("img", {"alt": image_file.read().decode("ascii")})]
image = documents.image(alt_text=None, content_type="image/png", open=lambda: io.BytesIO(b"abc"))
result = convert_document_element_to_html(image, convert_image=convert_image)
diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py
index d749b4c..677a97b 100644
--- a/tests/mammoth_tests.py
+++ b/tests/mammoth_tests.py
@@ -195,21 +195,21 @@ def text_boxes_are_read():
def underline_is_ignored_by_default():
with open(test_path("underline.docx"), "rb") as fileobj:
result = mammoth.convert_to_html(fileobj=fileobj)
- assert_equal('<p><strong>The </strong><strong>Sunset</strong><strong> Tree</strong></p>', result.value)
+ assert_equal('<p><strong>The Sunset Tree</strong></p>', result.value)
@istest
def underline_can_be_configured_with_convert_underline_option():
with open(test_path("underline.docx"), "rb") as fileobj:
result = mammoth.convert_to_html(fileobj=fileobj, convert_underline=mammoth.underline.element("em"))
- assert_equal('<p><strong>The </strong><strong><em>Sunset</em></strong><strong> Tree</strong></p>', result.value)
+ assert_equal('<p><strong>The <em>Sunset</em> Tree</strong></p>', result.value)
@istest
def underline_can_be_configured_with_style_mapping():
with open(test_path("underline.docx"), "rb") as fileobj:
result = mammoth.convert_to_html(fileobj=fileobj, style_map="u => em")
- assert_equal('<p><strong>The </strong><strong><em>Sunset</em></strong><strong> Tree</strong></p>', result.value)
+ assert_equal('<p><strong>The <em>Sunset</em> Tree</strong></p>', result.value)
@istest