diff options
| author | Alex Marchant | 2024-04-03 15:03:33 -0400 |
|---|---|---|
| committer | Alex Marchant | 2024-04-03 15:03:33 -0400 |
| commit | 1b9ce34e2c3da718e79137e2c2210ccdcd299486 (patch) | |
| tree | d780ad1350206b36839896201777d67bb3f05190 /tests/test_libmat2.py | |
| parent | 17e76ab6f0f2f3ffdf0c2c2a09f37378de69e740 (diff) | |
Add test that checks if comments.xml is removed without errors
Diffstat (limited to 'tests/test_libmat2.py')
| -rw-r--r-- | tests/test_libmat2.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index c64e4cb..32ae543 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -858,3 +858,20 @@ class TestComplexOfficeFiles(unittest.TestCase): | |||
| 858 | 858 | ||
| 859 | os.remove(target) | 859 | os.remove(target) |
| 860 | os.remove(p.output_filename) | 860 | os.remove(p.output_filename) |
| 861 | |||
| 862 | class TextDocx(unittest.TestCase): | ||
| 863 | def test_comment_xml_is_removed(self): | ||
| 864 | with zipfile.ZipFile('./tests/data/comment.docx') as zipin: | ||
| 865 | # Check if 'word/comments.xml' exists in the zip | ||
| 866 | self.assertIn('word/comments.xml', zipin.namelist()) | ||
| 867 | |||
| 868 | shutil.copy('./tests/data/comment.docx', './tests/data/comment_clean.docx') | ||
| 869 | p = office.MSOfficeParser('./tests/data/comment_clean.docx') | ||
| 870 | self.assertTrue(p.remove_all()) | ||
| 871 | |||
| 872 | with zipfile.ZipFile('./tests/data/comment_clean.cleaned.docx') as zipin: | ||
| 873 | # Check if 'word/comments.xml' exists in the zip | ||
| 874 | self.assertNotIn('word/comments.xml', zipin.namelist()) | ||
| 875 | |||
| 876 | os.remove('./tests/data/comment_clean.docx') | ||
| 877 | os.remove('./tests/data/comment_clean.cleaned.docx') \ No newline at end of file | ||
