From f3cef319b90a5a82ca879380c213651d74390a72 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Wed, 5 Sep 2018 18:49:35 -0400 Subject: Unknown Members: make policy use an Enum Closes #60 Note: this changeset also ensures that clean.cleaned.docx is removed up after the pytest is over. --- tests/test_policy.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests/test_policy.py') diff --git a/tests/test_policy.py b/tests/test_policy.py index 39282b1..5a8447b 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -4,28 +4,29 @@ import unittest import shutil import os -from libmat2 import office +from libmat2 import office, UnknownMemberPolicy class TestPolicy(unittest.TestCase): def test_policy_omit(self): shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') p = office.MSOfficeParser('./tests/data/clean.docx') - p.unknown_member_policy = 'omit' + p.unknown_member_policy = UnknownMemberPolicy.OMIT self.assertTrue(p.remove_all()) os.remove('./tests/data/clean.docx') + os.remove('./tests/data/clean.cleaned.docx') def test_policy_keep(self): shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') p = office.MSOfficeParser('./tests/data/clean.docx') - p.unknown_member_policy = 'keep' + p.unknown_member_policy = UnknownMemberPolicy.KEEP self.assertTrue(p.remove_all()) os.remove('./tests/data/clean.docx') + os.remove('./tests/data/clean.cleaned.docx') def test_policy_unknown(self): shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') p = office.MSOfficeParser('./tests/data/clean.docx') - p.unknown_member_policy = 'unknown_policy_name_totally_invalid' with self.assertRaises(ValueError): - p.remove_all() + p.unknown_member_policy = UnknownMemberPolicy('unknown_policy_name_totally_invalid') os.remove('./tests/data/clean.docx') -- cgit v1.3