Strip comment references from document.xml
This commit is contained in:
parent
f931a0ecee
commit
f2c898c92d
2 changed files with 67 additions and 1 deletions
|
@ -900,4 +900,34 @@ class TextDocx(unittest.TestCase):
|
|||
self.assertIsNotNone(match)
|
||||
|
||||
os.remove('./tests/data/comment_clean.docx')
|
||||
os.remove('./tests/data/comment_clean.cleaned.docx')
|
||||
os.remove('./tests/data/comment_clean.cleaned.docx')
|
||||
|
||||
def test_comment_references_are_removed(self):
|
||||
with zipfile.ZipFile('./tests/data/comment.docx') as zipin:
|
||||
c = zipin.open('word/document.xml')
|
||||
content = c.read()
|
||||
|
||||
r = b'w:commentRangeStart'
|
||||
self.assertIn(r, content)
|
||||
r = b'w:commentRangeEnd'
|
||||
self.assertIn(r, content)
|
||||
r = b'w:commentReference'
|
||||
self.assertIn(r, content)
|
||||
|
||||
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:
|
||||
c = zipin.open('word/document.xml')
|
||||
content = c.read()
|
||||
|
||||
r = b'w:commentRangeStart'
|
||||
self.assertNotIn(r, content)
|
||||
r = b'w:commentRangeEnd'
|
||||
self.assertNotIn(r, content)
|
||||
r = b'w:commentReference'
|
||||
self.assertNotIn(r, content)
|
||||
|
||||
os.remove('./tests/data/comment_clean.docx')
|
||||
os.remove('./tests/data/comment_clean.cleaned.docx')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue