1
0
mirror of synced 2024-11-22 01:04:23 +01:00

Add test that checks if comments.xml is removed without errors

This commit is contained in:
Alex Marchant 2024-04-03 15:03:33 -04:00
parent 17e76ab6f0
commit 1b9ce34e2c
2 changed files with 17 additions and 0 deletions

BIN
tests/data/comment.docx Normal file

Binary file not shown.

View File

@ -858,3 +858,20 @@ class TestComplexOfficeFiles(unittest.TestCase):
os.remove(target) os.remove(target)
os.remove(p.output_filename) os.remove(p.output_filename)
class TextDocx(unittest.TestCase):
def test_comment_xml_is_removed(self):
with zipfile.ZipFile('./tests/data/comment.docx') as zipin:
# Check if 'word/comments.xml' exists in the zip
self.assertIn('word/comments.xml', zipin.namelist())
shutil.copy('./tests/data/comment.docx', './tests/data/comment_clean.docx')
p = office.MSOfficeParser('./tests/data/comment_clean.docx')
self.assertTrue(p.remove_all())
with zipfile.ZipFile('./tests/data/comment_clean.cleaned.docx') as zipin:
# Check if 'word/comments.xml' exists in the zip
self.assertNotIn('word/comments.xml', zipin.namelist())
os.remove('./tests/data/comment_clean.docx')
os.remove('./tests/data/comment_clean.cleaned.docx')