From 74c9f604aa9118ef3693a00714baa4e3f24e21d5 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 17 May 2015 16:32:49 +0100 Subject: Add ignore_empty_paragraphs option --- tests/mammoth_tests.py | 16 ++++++++++++++++ tests/test-data/empty.docx | Bin 0 -> 3306 bytes 2 files changed, 16 insertions(+) create mode 100644 tests/test-data/empty.docx (limited to 'tests') diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py index ce76221..d9f1093 100644 --- a/tests/mammoth_tests.py +++ b/tests/mammoth_tests.py @@ -25,6 +25,22 @@ def can_read_xml_files_with_utf8_bom(): assert_equal([], result.messages) +@istest +def empty_paragraphs_are_ignored_by_default(): + with open(test_path("empty.docx"), "rb") as fileobj: + result = mammoth.convert_to_html(fileobj=fileobj) + assert_equal("", result.value) + assert_equal([], result.messages) + + +@istest +def empty_paragraphs_are_preserved_if_ignore_empty_paragraphs_is_false(): + with open(test_path("empty.docx"), "rb") as fileobj: + result = mammoth.convert_to_html(fileobj=fileobj, ignore_empty_paragraphs=False) + assert_equal("

", result.value) + assert_equal([], result.messages) + + @istest def inline_images_are_included_in_output(): with open(test_path("tiny-picture.docx"), "rb") as fileobj: diff --git a/tests/test-data/empty.docx b/tests/test-data/empty.docx new file mode 100644 index 0000000..e10b869 Binary files /dev/null and b/tests/test-data/empty.docx differ -- cgit v1.2.3