From 132d257befc2088a98b3fe10aa71713338d15673 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 3 Nov 2021 20:30:02 -0700 Subject: add test for XML parse exception behavior --- tests/test_errors.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_errors.py (limited to 'tests/test_errors.py') diff --git a/tests/test_errors.py b/tests/test_errors.py new file mode 100644 index 0000000..8537551 --- /dev/null +++ b/tests/test_errors.py @@ -0,0 +1,23 @@ +import xml.etree.ElementTree + +import pytest + +from grobid_tei_xml import parse_citation_list_xml + + +def test_doc_parse_error() -> None: + """ + This XML document has a bare '&' (should be '&') and results in a parse + error. + + See also: https://github.com/kermitt2/grobid/issues/848 + + The intent of this test is to ensure that the exception raised is the one + expected, especially if that behavior changes in the future. + """ + + with open("tests/files/citation_list/parse_error.tei.xml", "r") as f: + tei_xml = f.read() + + with pytest.raises(xml.etree.ElementTree.ParseError): + parse_citation_list_xml(tei_xml) -- cgit v1.2.3