aboutsummaryrefslogtreecommitdiff
path: root/tests/docx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/docx')
-rw-r--r--tests/docx/body_xml_tests.py27
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,