summaryrefslogtreecommitdiff
path: root/tests/test_policy.py
diff options
context:
space:
mode:
authorjvoisin2019-10-12 13:32:04 -0700
committerjvoisin2019-10-12 13:32:04 -0700
commit3cef7fe7fc81c1495a461a8594b1df69467536ea (patch)
tree2ddf7b8e181f7e606227dabdfc020fab4d4b4250 /tests/test_policy.py
parent6d19a209355a7d1ef3bbee32ec7c9be93ed666ad (diff)
Refactor tests
Diffstat (limited to 'tests/test_policy.py')
-rw-r--r--tests/test_policy.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/test_policy.py b/tests/test_policy.py
index ef55644..206c92d 100644
--- a/tests/test_policy.py
+++ b/tests/test_policy.py
@@ -7,25 +7,26 @@ import os
7from libmat2 import office, UnknownMemberPolicy 7from libmat2 import office, UnknownMemberPolicy
8 8
9class TestPolicy(unittest.TestCase): 9class TestPolicy(unittest.TestCase):
10 target = './tests/data/clean.docx'
11
10 def test_policy_omit(self): 12 def test_policy_omit(self):
11 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') 13 shutil.copy('./tests/data/embedded.docx', self.target)
12 p = office.MSOfficeParser('./tests/data/clean.docx') 14 p = office.MSOfficeParser(self.target)
13 p.unknown_member_policy = UnknownMemberPolicy.OMIT 15 p.unknown_member_policy = UnknownMemberPolicy.OMIT
14 self.assertTrue(p.remove_all()) 16 self.assertTrue(p.remove_all())
15 os.remove('./tests/data/clean.docx') 17 os.remove(p.filename)
16 os.remove('./tests/data/clean.cleaned.docx')
17 18
18 def test_policy_keep(self): 19 def test_policy_keep(self):
19 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') 20 shutil.copy('./tests/data/embedded.docx', self.target)
20 p = office.MSOfficeParser('./tests/data/clean.docx') 21 p = office.MSOfficeParser(self.target)
21 p.unknown_member_policy = UnknownMemberPolicy.KEEP 22 p.unknown_member_policy = UnknownMemberPolicy.KEEP
22 self.assertTrue(p.remove_all()) 23 self.assertTrue(p.remove_all())
23 os.remove('./tests/data/clean.docx') 24 os.remove(p.filename)
24 os.remove('./tests/data/clean.cleaned.docx') 25 os.remove(p.output_filename)
25 26
26 def test_policy_unknown(self): 27 def test_policy_unknown(self):
27 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') 28 shutil.copy('./tests/data/embedded.docx', self.target)
28 p = office.MSOfficeParser('./tests/data/clean.docx') 29 p = office.MSOfficeParser(self.target)
29 with self.assertRaises(ValueError): 30 with self.assertRaises(ValueError):
30 p.unknown_member_policy = UnknownMemberPolicy('unknown_policy_name_totally_invalid') 31 p.unknown_member_policy = UnknownMemberPolicy('unknown_policy_name_totally_invalid')
31 os.remove('./tests/data/clean.docx') 32 os.remove(p.filename)