aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-05-28 19:56:36 +0100
committerMichael Williamson <mike@zwobble.org>2025-05-28 19:56:36 +0100
commite7041cb3e4188c24ca6efbd383df183518d7840d (patch)
treef54154b2853ff55825396ac8c39da2fc2a93d313 /tests
parenta095ca26ed2a0a5394ecd43e927a063b9a30542b (diff)
Ignore AlternateContent elements when there is no Fallback element
Diffstat (limited to 'tests')
-rw-r--r--tests/docx/body_xml_tests.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py
index 8a8f40b..424c2f5 100644
--- a/tests/docx/body_xml_tests.py
+++ b/tests/docx/body_xml_tests.py
@@ -1406,17 +1406,30 @@ def test_text_boxes_have_content_appended_after_containing_paragraph():
result = _read_and_get_document_xml_elements(paragraph)
assert_equal(result[1].style_id, "textbox-content")
-def test_alternate_content_is_read_using_fallback():
- element = xml_element("mc:AlternateContent", {}, [
- xml_element("mc:Choice", {"Requires": "wps"}, [
- _paragraph_with_style_id("first")
- ]),
- xml_element("mc:Fallback", {}, [
- _paragraph_with_style_id("second")
+
+class AlternateContentTests(object):
+ def test_when_fallback_is_present_then_fallback_is_read(self):
+ element = xml_element("mc:AlternateContent", {}, [
+ xml_element("mc:Choice", {"Requires": "wps"}, [
+ _paragraph_with_style_id("first")
+ ]),
+ xml_element("mc:Fallback", {}, [
+ _paragraph_with_style_id("second")
+ ])
])
- ])
- result = _read_and_get_document_xml_element(element)
- assert_equal("second", result.style_id)
+ result = _read_and_get_document_xml_element(element)
+ assert_equal("second", result.style_id)
+
+
+ def test_when_fallback_is_not_present_then_element_is_ignored(self):
+ element = xml_element("mc:AlternateContent", {}, [
+ xml_element("mc:Choice", {"Requires": "wps"}, [
+ _paragraph_with_style_id("first")
+ ]),
+ ])
+ result = _read_and_get_document_xml_elements(element)
+ assert_equal([], result)
+
def test_sdt_is_read_using_sdt_content():
element = xml_element("w:sdt", {}, [