diff options
| author | Alex Marchant | 2024-04-03 15:20:00 -0400 |
|---|---|---|
| committer | Alex Marchant | 2024-04-03 15:20:00 -0400 |
| commit | 61f39c4bd0b51be6371fb2973c14054a2772352e (patch) | |
| tree | 3f5a8c11eb8c37fbc229a213a6e89ade3b5272b0 /tests/test_libmat2.py | |
| parent | 1b9ce34e2c3da718e79137e2c2210ccdcd299486 (diff) | |
Strip comment references from document.xml
Diffstat (limited to 'tests/test_libmat2.py')
| -rw-r--r-- | tests/test_libmat2.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 32ae543..d199f54 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -874,4 +874,34 @@ 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_comment_references_are_removed(self): | ||
| 880 | with zipfile.ZipFile('./tests/data/comment.docx') as zipin: | ||
| 881 | c = zipin.open('word/document.xml') | ||
| 882 | content = c.read() | ||
| 883 | |||
| 884 | r = b'w:commentRangeStart' | ||
| 885 | self.assertIn(r, content) | ||
| 886 | r = b'w:commentRangeEnd' | ||
| 887 | self.assertIn(r, content) | ||
| 888 | r = b'w:commentReference' | ||
| 889 | self.assertIn(r, content) | ||
| 890 | |||
| 891 | shutil.copy('./tests/data/comment.docx', './tests/data/comment_clean.docx') | ||
| 892 | p = office.MSOfficeParser('./tests/data/comment_clean.docx') | ||
| 893 | self.assertTrue(p.remove_all()) | ||
| 894 | |||
| 895 | with zipfile.ZipFile('./tests/data/comment_clean.cleaned.docx') as zipin: | ||
| 896 | c = zipin.open('word/document.xml') | ||
| 897 | content = c.read() | ||
| 898 | |||
| 899 | r = b'w:commentRangeStart' | ||
| 900 | self.assertNotIn(r, content) | ||
| 901 | r = b'w:commentRangeEnd' | ||
| 902 | self.assertNotIn(r, content) | ||
| 903 | r = b'w:commentReference' | ||
| 904 | self.assertNotIn(r, content) | ||
| 905 | |||
| 906 | os.remove('./tests/data/comment_clean.docx') | ||
| 877 | os.remove('./tests/data/comment_clean.cleaned.docx') \ No newline at end of file | 907 | os.remove('./tests/data/comment_clean.cleaned.docx') \ No newline at end of file |
