summaryrefslogtreecommitdiff
path: root/tests/test_libmat2.py
diff options
context:
space:
mode:
authorAlex Marchant2024-04-03 15:27:48 -0400
committerAlex Marchant2024-04-03 15:27:48 -0400
commitf931a0eceed3a89ef7c94a8a7b2bbed208bf0295 (patch)
tree18a47539de82c034ee753b947f157598fa4c6dc4 /tests/test_libmat2.py
parent1b9ce34e2c3da718e79137e2c2210ccdcd299486 (diff)
Make utf-8 explicit in all tree.write calls
Diffstat (limited to 'tests/test_libmat2.py')
-rw-r--r--tests/test_libmat2.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 32ae543..0435113 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -874,4 +874,30 @@ class TextDocx(unittest.TestCase):
874 self.assertNotIn('word/comments.xml', zipin.namelist()) 874 self.assertNotIn('word/comments.xml', zipin.namelist())
875 875
876 os.remove('./tests/data/comment_clean.docx') 876 os.remove('./tests/data/comment_clean.docx')
877 os.remove('./tests/data/comment_clean.cleaned.docx')
878
879 def test_xml_is_utf8(self):
880 with zipfile.ZipFile('./tests/data/comment.docx') as zipin:
881 c = zipin.open('word/document.xml')
882 content = c.read()
883
884 # ensure encoding is utf-8
885 r = b'encoding=(\'|\")UTF-8(\'|\")'
886 match = re.search(r, content, re.IGNORECASE)
887 self.assertIsNotNone(match)
888
889 shutil.copy('./tests/data/comment.docx', './tests/data/comment_clean.docx')
890 p = office.MSOfficeParser('./tests/data/comment_clean.docx')
891 self.assertTrue(p.remove_all())
892
893 with zipfile.ZipFile('./tests/data/comment_clean.cleaned.docx') as zipin:
894 c = zipin.open('word/document.xml')
895 content = c.read()
896
897 # ensure encoding is still utf-8
898 r = b'encoding=(\'|\")UTF-8(\'|\")'
899 match = re.search(r, content, re.IGNORECASE)
900 self.assertIsNotNone(match)
901
902 os.remove('./tests/data/comment_clean.docx')
877 os.remove('./tests/data/comment_clean.cleaned.docx') \ No newline at end of file 903 os.remove('./tests/data/comment_clean.cleaned.docx') \ No newline at end of file