From 6e62be83305ba864caf8e6bc1afff954dc6f3d91 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 5 Dec 2026 10:21:42 +0000 Subject: Test behaviour of reader when XML is badly formed --- tests/docx/xmlparser_tests.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/docx/xmlparser_tests.py b/tests/docx/xmlparser_tests.py index 8c960eb..75fc35a 100644 --- a/tests/docx/xmlparser_tests.py +++ b/tests/docx/xmlparser_tests.py @@ -1,5 +1,7 @@ import io +import pytest + from mammoth.docx.xmlparser import parse_xml, element as xml_element, text as xml_text from ..testing import assert_equal @@ -54,6 +56,10 @@ def test_whitespace_between_xml_declaration_and_root_tag_is_ignored(): assert_equal("body", xml.name) +def test_error_if_xml_is_badly_formed(): + pytest.raises(Exception, lambda: _parse_xml_string(b'