diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-09-12 17:29:41 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-09-12 17:29:41 +0100 |
| commit | 7c4193e8325fa914d92287dd4dfdb8fc004cd5c6 (patch) | |
| tree | 710f1b9baf0441ceb6991e6407d4886fefca147b /tests | |
| parent | 2cf770c98de1851d9859e2787e10f0b77bcc7956 (diff) | |
Read embedded style if available
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mammoth_tests.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py index 906f49b..56ef159 100644 --- a/tests/mammoth_tests.py +++ b/tests/mammoth_tests.py @@ -46,6 +46,23 @@ def empty_paragraphs_are_preserved_if_ignore_empty_paragraphs_is_false(): assert_equal("<p></p>", result.value) assert_equal([], result.messages) + +@istest +def embedded_style_map_is_used_if_present(): + with _copy_of_test_data("single-paragraph.docx") as fileobj: + mammoth.embed_style_map(fileobj, "p => h1") + result = mammoth.convert_to_html(fileobj=fileobj, ignore_empty_paragraphs=False) + assert_equal("<h1>Walking on imported air</h1>", result.value) + assert_equal([], result.messages) + + +@istest +def embedded_style_map_can_be_retrieved(): + with _copy_of_test_data("single-paragraph.docx") as fileobj: + mammoth.embed_style_map(fileobj, "p => h1") + assert_equal("p => h1", mammoth.read_embedded_style_map(fileobj)) + + @istest def warning_if_style_mapping_is_not_understood(): style_map = """ @@ -236,3 +253,9 @@ def can_extract_raw_text(): assert_equal([], result.messages) assert_equal("Apple\n\nBanana\n\n", result.value) + +def _copy_of_test_data(path): + destination = io.BytesIO() + with open(test_path(path), "rb") as source: + shutil.copyfileobj(source, destination) + return destination |
