Improve the previous commit
This commit is contained in:
parent
1d7e374e5b
commit
46bb1b83ea
4 changed files with 40 additions and 7 deletions
|
@ -8,13 +8,13 @@ class TestHelp(unittest.TestCase):
|
|||
def test_help(self):
|
||||
proc = subprocess.Popen(['./mat2', '--help'], stdout=subprocess.PIPE)
|
||||
stdout, _ = proc.communicate()
|
||||
self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-V] [-u POLICY] [-s | -L] [files [files ...]]',
|
||||
self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-V] [-u policy] [-s | -L] [files [files ...]]',
|
||||
stdout)
|
||||
|
||||
def test_no_arg(self):
|
||||
proc = subprocess.Popen(['./mat2'], stdout=subprocess.PIPE)
|
||||
stdout, _ = proc.communicate()
|
||||
self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-V] [-u POLICY] [-s | -L] [files [files ...]]',
|
||||
self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-V] [-u policy] [-s | -L] [files [files ...]]',
|
||||
stdout)
|
||||
|
||||
|
||||
|
|
31
tests/test_policy.py
Normal file
31
tests/test_policy.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import unittest
|
||||
import shutil
|
||||
import os
|
||||
|
||||
from libmat2 import office
|
||||
|
||||
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'
|
||||
self.assertTrue(p.remove_all())
|
||||
os.remove('./tests/data/clean.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'
|
||||
self.assertTrue(p.remove_all())
|
||||
os.remove('./tests/data/clean.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()
|
||||
os.remove('./tests/data/clean.docx')
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue