summaryrefslogtreecommitdiff
path: root/tests/docx/office_xml_tests.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-12-05 11:06:47 +0000
committerMichael Williamson <mike@zwobble.org>2026-12-05 11:06:47 +0000
commit659c4ffe6ade2d8132873ae3f3f3a22df38fdb37 (patch)
treea5e6dab4c6259ee306a4cac6c089876e52823aa1 /tests/docx/office_xml_tests.py
parent6e62be83305ba864caf8e6bc1afff954dc6f3d91 (diff)
Handle XML documents that are missing a root element
Diffstat (limited to 'tests/docx/office_xml_tests.py')
-rw-r--r--tests/docx/office_xml_tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/docx/office_xml_tests.py b/tests/docx/office_xml_tests.py
index 05897db..34566ff 100644
--- a/tests/docx/office_xml_tests.py
+++ b/tests/docx/office_xml_tests.py
@@ -2,10 +2,18 @@ from __future__ import unicode_literals
import io
+import pytest
+
from mammoth.docx import xmlparser as xml, office_xml
from ..testing import assert_equal
+def test_when_document_is_missing_root_element_then_none_is_returned():
+ xml_string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
+
+ pytest.raises(xml.NoRootElementError, lambda: office_xml.read(io.StringIO(xml_string)))
+
+
class AlternateContentTests(object):
def test_when_fallback_is_present_then_fallback_is_read(self):
xml_string = (