diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-11-06 18:32:35 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-11-06 18:32:35 -0800 |
commit | 175019c96fced3e21d0f60ea1a4a37da6b8872ac (patch) | |
tree | f42fbbe9c8ac06ae9eb06373ab9eec96d2b3a177 /python/tests/test_xml.py | |
parent | b0b66c20c6ffb9d8acc626068964d7dfd5d3bcdc (diff) | |
parent | 47ca1a273912c8836630b0930b71a4e66fd2c85b (diff) | |
download | sandcrawler-175019c96fced3e21d0f60ea1a4a37da6b8872ac.tar.gz sandcrawler-175019c96fced3e21d0f60ea1a4a37da6b8872ac.zip |
Merge branch 'bnewbold-html-ingest'
Diffstat (limited to 'python/tests/test_xml.py')
-rw-r--r-- | python/tests/test_xml.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/python/tests/test_xml.py b/python/tests/test_xml.py new file mode 100644 index 0000000..a996c56 --- /dev/null +++ b/python/tests/test_xml.py @@ -0,0 +1,18 @@ + +import pytest + +from sandcrawler.xml import xml_reserialize + + +def test_xml_reserialize() -> None: + + with open('tests/files/scielo_article.jats.xml', 'rb') as f: + raw_xml = f.read() + + assert b'encoding="ISO-8859-1"' in raw_xml + raw_xml.decode("ISO-8859-1") + with pytest.raises(UnicodeDecodeError): + raw_xml.decode("utf-8") + + str_xml = xml_reserialize(raw_xml) + assert 'encoding="UTF-8"' in str_xml |