diff options
author | Bryan Newbold <bnewbold@archive.org> | 2021-10-21 13:31:27 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2021-10-21 13:31:27 -0700 |
commit | 2f3fd33c33f12b4426072a0279de85ff797611fe (patch) | |
tree | 089d0eb973ae78c9750ee57239950fe88feba927 /tests/test_grobid2json.py | |
download | grobid_tei_xml-2f3fd33c33f12b4426072a0279de85ff797611fe.tar.gz grobid_tei_xml-2f3fd33c33f12b4426072a0279de85ff797611fe.zip |
init project from existing code and tests in sandcrawler, fatcat-scholar, fuzzycat, etc
Diffstat (limited to 'tests/test_grobid2json.py')
-rw-r--r-- | tests/test_grobid2json.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_grobid2json.py b/tests/test_grobid2json.py new file mode 100644 index 0000000..8497b10 --- /dev/null +++ b/tests/test_grobid2json.py @@ -0,0 +1,22 @@ + +import xml +import json +import pytest +from grobid2json import * + + +def test_small_xml(): + + with open('tests/files/small.xml', 'r') as f: + tei_xml = f.read() + with open('tests/files/small.json', 'r') as f: + json_form = json.loads(f.read()) + + assert teixml2json(tei_xml) == json_form + +def test_invalid_xml(): + + with pytest.raises(xml.etree.ElementTree.ParseError): + teixml2json("this is not XML") + with pytest.raises(ValueError): + teixml2json("<xml></xml>") |