diff options
| author | Michael Williamson <mike@zwobble.org> | 2021-08-01 17:20:33 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2021-08-01 17:20:33 +0100 |
| commit | b537a3713700b4fc40a23d0ca51b11846d562328 (patch) | |
| tree | 19a8ddebc9ac8f36c1fc01b806982b46bcded2fc /tests/docx/body_xml_tests.py | |
| parent | 30d24cb9dee83df7a1b108fbc83cdfec31b81b9a (diff) | |
Handle internal hyperlinks created with complex fields
Diffstat (limited to 'tests/docx/body_xml_tests.py')
| -rw-r--r-- | tests/docx/body_xml_tests.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py index 664b438..4cd54eb 100644 --- a/tests/docx/body_xml_tests.py +++ b/tests/docx/body_xml_tests.py @@ -418,7 +418,7 @@ class ComplexFieldTests(object): return self._is_hyperlinked_run(children=[]) @istest - def runs_in_a_complex_field_for_hyperlinks_are_read_as_hyperlinks(self): + def runs_in_a_complex_field_for_hyperlinks_without_switch_are_read_as_external_hyperlinks(self): element = xml_element("w:p", {}, [ self._BEGIN_COMPLEX_FIELD, self._HYPERLINK_INSTRTEXT, @@ -441,6 +441,31 @@ class ComplexFieldTests(object): ))) @istest + def runs_in_a_complex_field_for_hyperlinks_with_l_switch_are_read_as_internal_hyperlinks(self): + element = xml_element("w:p", {}, [ + self._BEGIN_COMPLEX_FIELD, + xml_element("w:instrText", {}, [ + xml_text(' HYPERLINK \\l "InternalLink"'), + ]), + self._SEPARATE_COMPLEX_FIELD, + _run_element_with_text("this is a hyperlink"), + self._END_COMPLEX_FIELD, + ]) + paragraph = _read_and_get_document_xml_element(element) + + assert_that(paragraph, is_paragraph(children=is_sequence( + is_empty_run, + self._is_empty_hyperlinked_run, + self._is_hyperlinked_run( + anchor="InternalLink", + children=is_sequence( + is_text("this is a hyperlink"), + ), + ), + is_empty_run, + ))) + + @istest def runs_after_a_complex_field_for_hyperlinks_are_not_read_as_hyperlinks(self): element = xml_element("w:p", {}, [ self._BEGIN_COMPLEX_FIELD, |
