From d0b4eb76001049a23fe038025cfa56472703fa70 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 18 May 2017 20:12:25 +0100 Subject: Avoid parsing URI when replacing fragment --- tests/docx/body_xml_tests.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py index 1277238..cccf472 100644 --- a/tests/docx/body_xml_tests.py +++ b/tests/docx/body_xml_tests.py @@ -623,6 +623,18 @@ class HyperlinkTests(object): _read_and_get_document_xml_element(element, relationships=relationships) ) + @istest + def existing_fragment_is_replaced_when_anchor_is_set_on_external_link(self): + relationships = Relationships({ + "r42": Relationship(target="http://example.com/#previous") + }) + run_element = xml_element("w:r") + element = xml_element("w:hyperlink", {"r:id": "r42", "w:anchor": "fragment"}, [run_element]) + assert_equal( + documents.hyperlink(href="http://example.com/#fragment", children=[documents.run([])]), + _read_and_get_document_xml_element(element, relationships=relationships) + ) + @istest def hyperlink_is_read_as_internal_hyperlink_if_it_has_an_anchor_attribute(self): run_element = xml_element("w:r") -- cgit v1.2.3