diff options
| author | Alex Marchant | 2024-04-03 15:20:00 -0400 |
|---|---|---|
| committer | jvoisin | 2024-04-05 18:31:49 +0200 |
| commit | f2c898c92d0422ddc76fa977d60f7345b06a5ad6 (patch) | |
| tree | 3ba30c593b342a8f6f1de1974767ea653aef0918 /tests/test_libmat2.py | |
| parent | f931a0eceed3a89ef7c94a8a7b2bbed208bf0295 (diff) | |
Strip comment references from document.xml
Diffstat (limited to 'tests/test_libmat2.py')
| -rw-r--r-- | tests/test_libmat2.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 0435113..491f396 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -900,4 +900,34 @@ class TextDocx(unittest.TestCase): | |||
| 900 | self.assertIsNotNone(match) | 900 | self.assertIsNotNone(match) |
| 901 | 901 | ||
| 902 | os.remove('./tests/data/comment_clean.docx') | 902 | os.remove('./tests/data/comment_clean.docx') |
| 903 | os.remove('./tests/data/comment_clean.cleaned.docx') \ No newline at end of file | 903 | os.remove('./tests/data/comment_clean.cleaned.docx') |
| 904 | |||
| 905 | def test_comment_references_are_removed(self): | ||
| 906 | with zipfile.ZipFile('./tests/data/comment.docx') as zipin: | ||
| 907 | c = zipin.open('word/document.xml') | ||
| 908 | content = c.read() | ||
| 909 | |||
| 910 | r = b'w:commentRangeStart' | ||
| 911 | self.assertIn(r, content) | ||
| 912 | r = b'w:commentRangeEnd' | ||
| 913 | self.assertIn(r, content) | ||
| 914 | r = b'w:commentReference' | ||
| 915 | self.assertIn(r, content) | ||
| 916 | |||
| 917 | shutil.copy('./tests/data/comment.docx', './tests/data/comment_clean.docx') | ||
| 918 | p = office.MSOfficeParser('./tests/data/comment_clean.docx') | ||
| 919 | self.assertTrue(p.remove_all()) | ||
| 920 | |||
| 921 | with zipfile.ZipFile('./tests/data/comment_clean.cleaned.docx') as zipin: | ||
| 922 | c = zipin.open('word/document.xml') | ||
| 923 | content = c.read() | ||
| 924 | |||
| 925 | r = b'w:commentRangeStart' | ||
| 926 | self.assertNotIn(r, content) | ||
| 927 | r = b'w:commentRangeEnd' | ||
| 928 | self.assertNotIn(r, content) | ||
| 929 | r = b'w:commentReference' | ||
| 930 | self.assertNotIn(r, content) | ||
| 931 | |||
| 932 | os.remove('./tests/data/comment_clean.docx') | ||
| 933 | os.remove('./tests/data/comment_clean.cleaned.docx') | ||
