diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-01-25 17:06:54 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-01-25 17:06:54 +0000 |
| commit | 1483a864719cedabc0d6c6bcd98e0b2d9d3ce0c1 (patch) | |
| tree | 8f5db7dde7d0f1952890f5ba97af7c958c212d13 /tests | |
| parent | abdcd67365d663c878fd370cb97e77ce74c2b1a7 (diff) | |
Use prefix to generate IDs
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/conversion_tests.py | 10 | ||||
| -rw-r--r-- | tests/docx/document_xml_tests.py | 2 | ||||
| -rw-r--r-- | tests/mammoth_tests.py | 20 |
3 files changed, 16 insertions, 16 deletions
diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py index 39c57cd..78fbce5 100644 --- a/tests/conversion_tests.py +++ b/tests/conversion_tests.py @@ -289,9 +289,9 @@ def footnote_reference_is_converted_to_superscript_intra_page_link(): footnote_reference = documents.note_reference("footnote", "4") result = convert_document_element_to_html( footnote_reference, - generate_uniquifier=lambda: 42 + id_prefix="doc-42" ) - assert_equal('<sup><a href="#footnote-42-4" id="footnote-ref-42-4">[1]</a></sup>', result.value) + assert_equal('<sup><a href="#doc-42-footnote-4" id="doc-42-footnote-ref-4">[1]</a></sup>', result.value) @istest @@ -308,10 +308,10 @@ def footnotes_are_included_after_the_main_body(): ) result = convert_document_element_to_html( document, - generate_uniquifier=lambda: 42 + id_prefix="doc-42" ) - expected_html = ('<p>Knock knock<sup><a href="#footnote-42-4" id="footnote-ref-42-4">[1]</a></sup></p>' + - '<ol><li id="footnote-42-4"><p>Who\'s there? <a href="#footnote-ref-42-4">↑</a></p></li></ol>') + expected_html = ('<p>Knock knock<sup><a href="#doc-42-footnote-4" id="doc-42-footnote-ref-4">[1]</a></sup></p>' + + '<ol><li id="doc-42-footnote-4"><p>Who\'s there? <a href="#doc-42-footnote-ref-4">↑</a></p></li></ol>') assert_equal(expected_html, result.value) diff --git a/tests/docx/document_xml_tests.py b/tests/docx/document_xml_tests.py index a0d29b9..a2eefaf 100644 --- a/tests/docx/document_xml_tests.py +++ b/tests/docx/document_xml_tests.py @@ -322,7 +322,7 @@ class ReadXmlElementTests(object): document = _read_and_get_document_xml_element(document_xml, footnote_elements=footnotes) footnote = document.notes.find_note("footnote", "4") - assert_equal("4", footnote.id) + assert_equal("4", footnote.note_id) assert isinstance(footnote.body[0], documents.Paragraph) @istest diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py index 79ce50c..c5f2557 100644 --- a/tests/mammoth_tests.py +++ b/tests/mammoth_tests.py @@ -61,13 +61,13 @@ def word_tables_are_converted_to_html_tables(): def footnotes_are_appended_to_text(): # TODO: don't duplicate footnotes with multiple references expected_html = ('<p>Ouch' + - '<sup><a href="#footnote-42-1" id="footnote-ref-42-1">[1]</a></sup>.' + - '<sup><a href="#footnote-42-2" id="footnote-ref-42-2">[2]</a></sup></p>' + - '<ol><li id="footnote-42-1"><p> A tachyon walks into a bar. <a href="#footnote-ref-42-1">↑</a></p></li>' + - '<li id="footnote-42-2"><p> Fin. <a href="#footnote-ref-42-2">↑</a></p></li></ol>') + '<sup><a href="#doc-42-footnote-1" id="doc-42-footnote-ref-1">[1]</a></sup>.' + + '<sup><a href="#doc-42-footnote-2" id="doc-42-footnote-ref-2">[2]</a></sup></p>' + + '<ol><li id="doc-42-footnote-1"><p> A tachyon walks into a bar. <a href="#doc-42-footnote-ref-1">↑</a></p></li>' + + '<li id="doc-42-footnote-2"><p> Fin. <a href="#doc-42-footnote-ref-2">↑</a></p></li></ol>') with open(test_path("footnotes.docx"), "rb") as fileobj: - result = mammoth.convert_to_html(fileobj=fileobj, generate_uniquifier=lambda: 42) + result = mammoth.convert_to_html(fileobj=fileobj, id_prefix="doc-42") assert_equal([], result.messages) assert_equal(expected_html, result.value) @@ -75,13 +75,13 @@ def footnotes_are_appended_to_text(): @istest def endnotes_are_appended_to_text(): expected_html = ('<p>Ouch' + - '<sup><a href="#endnote-42-2" id="endnote-ref-42-2">[1]</a></sup>.' + - '<sup><a href="#endnote-42-3" id="endnote-ref-42-3">[2]</a></sup></p>' + - '<ol><li id="endnote-42-2"><p> A tachyon walks into a bar. <a href="#endnote-ref-42-2">↑</a></p></li>' + - '<li id="endnote-42-3"><p> Fin. <a href="#endnote-ref-42-3">↑</a></p></li></ol>') + '<sup><a href="#doc-42-endnote-2" id="doc-42-endnote-ref-2">[1]</a></sup>.' + + '<sup><a href="#doc-42-endnote-3" id="doc-42-endnote-ref-3">[2]</a></sup></p>' + + '<ol><li id="doc-42-endnote-2"><p> A tachyon walks into a bar. <a href="#doc-42-endnote-ref-2">↑</a></p></li>' + + '<li id="doc-42-endnote-3"><p> Fin. <a href="#doc-42-endnote-ref-3">↑</a></p></li></ol>') with open(test_path("endnotes.docx"), "rb") as fileobj: - result = mammoth.convert_to_html(fileobj=fileobj, generate_uniquifier=lambda: 42) + result = mammoth.convert_to_html(fileobj=fileobj, id_prefix="doc-42") assert_equal([], result.messages) assert_equal(expected_html, result.value) |
