summaryrefslogtreecommitdiff
path: root/tests/docx/xmlparser_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/xmlparser_tests.py
parent6e62be83305ba864caf8e6bc1afff954dc6f3d91 (diff)
Handle XML documents that are missing a root element
Diffstat (limited to 'tests/docx/xmlparser_tests.py')
-rw-r--r--tests/docx/xmlparser_tests.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/docx/xmlparser_tests.py b/tests/docx/xmlparser_tests.py
index 75fc35a..65479fc 100644
--- a/tests/docx/xmlparser_tests.py
+++ b/tests/docx/xmlparser_tests.py
@@ -2,7 +2,7 @@ import io
import pytest
-from mammoth.docx.xmlparser import parse_xml, element as xml_element, text as xml_text
+from mammoth.docx.xmlparser import parse_xml, element as xml_element, text as xml_text, NoRootElementError
from ..testing import assert_equal
@@ -60,6 +60,13 @@ def test_error_if_xml_is_badly_formed():
pytest.raises(Exception, lambda: _parse_xml_string(b'<bo'))
+def test_when_document_is_missing_root_element_then_error_is_raised():
+ pytest.raises(
+ NoRootElementError,
+ lambda: _parse_xml_string(b'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'),
+ )
+
+
class FindChildTests(object):
def test_returns_none_if_no_children(self):
xml = xml_element("a")