From 3cef7fe7fc81c1495a461a8594b1df69467536ea Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 12 Oct 2019 13:32:04 -0700 Subject: Refactor tests --- tests/test_policy.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'tests/test_policy.py') 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 from libmat2 import office, UnknownMemberPolicy class TestPolicy(unittest.TestCase): + target = './tests/data/clean.docx' + def test_policy_omit(self): - shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') - p = office.MSOfficeParser('./tests/data/clean.docx') + shutil.copy('./tests/data/embedded.docx', self.target) + p = office.MSOfficeParser(self.target) p.unknown_member_policy = UnknownMemberPolicy.OMIT self.assertTrue(p.remove_all()) - os.remove('./tests/data/clean.docx') - os.remove('./tests/data/clean.cleaned.docx') + os.remove(p.filename) def test_policy_keep(self): - shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') - p = office.MSOfficeParser('./tests/data/clean.docx') + shutil.copy('./tests/data/embedded.docx', self.target) + p = office.MSOfficeParser(self.target) p.unknown_member_policy = UnknownMemberPolicy.KEEP self.assertTrue(p.remove_all()) - os.remove('./tests/data/clean.docx') - os.remove('./tests/data/clean.cleaned.docx') + os.remove(p.filename) + os.remove(p.output_filename) def test_policy_unknown(self): - shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') - p = office.MSOfficeParser('./tests/data/clean.docx') + shutil.copy('./tests/data/embedded.docx', self.target) + p = office.MSOfficeParser(self.target) with self.assertRaises(ValueError): p.unknown_member_policy = UnknownMemberPolicy('unknown_policy_name_totally_invalid') - os.remove('./tests/data/clean.docx') + os.remove(p.filename) -- cgit v1.3