summaryrefslogtreecommitdiff
path: root/tests/test_climat2.py
diff options
context:
space:
mode:
authorjvoisin2019-10-12 16:13:49 -0700
committerjvoisin2019-10-12 16:13:49 -0700
commit5f0b3beb46d09af26107fe5f80e63ddccb127a59 (patch)
treef3d46e6e9dac60daa304d212bed62b17c019f7eb /tests/test_climat2.py
parent3cef7fe7fc81c1495a461a8594b1df69467536ea (diff)
Add a way to disable the sandbox
Due to bubblewrap's pickiness, mat2 can now be run without a sandbox, even if bubblewrap is installed.
Diffstat (limited to 'tests/test_climat2.py')
-rw-r--r--tests/test_climat2.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/test_climat2.py b/tests/test_climat2.py
index 6cf8a39..9d816b1 100644
--- a/tests/test_climat2.py
+++ b/tests/test_climat2.py
@@ -20,17 +20,17 @@ class TestHelp(unittest.TestCase):
20 def test_help(self): 20 def test_help(self):
21 proc = subprocess.Popen(mat2_binary + ['--help'], stdout=subprocess.PIPE) 21 proc = subprocess.Popen(mat2_binary + ['--help'], stdout=subprocess.PIPE)
22 stdout, _ = proc.communicate() 22 stdout, _ = proc.communicate()
23 self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [--inplace] [-v] [-l]', 23 self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [--inplace] [--no-sandbox]',
24 stdout) 24 stdout)
25 self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) 25 self.assertIn(b' [-v] [-l] [--check-dependencies] [-L | -s]', stdout)
26 self.assertIn(b'[files [files ...]]', stdout) 26 self.assertIn(b'[files [files ...]]', stdout)
27 27
28 def test_no_arg(self): 28 def test_no_arg(self):
29 proc = subprocess.Popen(mat2_binary, stdout=subprocess.PIPE) 29 proc = subprocess.Popen(mat2_binary, stdout=subprocess.PIPE)
30 stdout, _ = proc.communicate() 30 stdout, _ = proc.communicate()
31 self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [--inplace] [-v] [-l]', 31 self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [--inplace] [--no-sandbox]',
32 stdout) 32 stdout)
33 self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) 33 self.assertIn(b' [-v] [-l] [--check-dependencies] [-L | -s]', stdout)
34 self.assertIn(b'[files [files ...]]', stdout) 34 self.assertIn(b'[files [files ...]]', stdout)
35 35
36 36
@@ -40,12 +40,14 @@ class TestVersion(unittest.TestCase):
40 stdout, _ = proc.communicate() 40 stdout, _ = proc.communicate()
41 self.assertTrue(stdout.startswith(b'MAT2 ')) 41 self.assertTrue(stdout.startswith(b'MAT2 '))
42 42
43
43class TestDependencies(unittest.TestCase): 44class TestDependencies(unittest.TestCase):
44 def test_dependencies(self): 45 def test_dependencies(self):
45 proc = subprocess.Popen(mat2_binary + ['--check-dependencies'], stdout=subprocess.PIPE) 46 proc = subprocess.Popen(mat2_binary + ['--check-dependencies'], stdout=subprocess.PIPE)
46 stdout, _ = proc.communicate() 47 stdout, _ = proc.communicate()
47 self.assertTrue(b'MAT2' in stdout) 48 self.assertTrue(b'MAT2' in stdout)
48 49
50
49class TestReturnValue(unittest.TestCase): 51class TestReturnValue(unittest.TestCase):
50 def test_nonzero(self): 52 def test_nonzero(self):
51 ret = subprocess.call(mat2_binary + ['mat2'], stdout=subprocess.DEVNULL) 53 ret = subprocess.call(mat2_binary + ['mat2'], stdout=subprocess.DEVNULL)
@@ -112,6 +114,25 @@ class TestCleanMeta(unittest.TestCase):
112 114
113 os.remove('./tests/data/clean.jpg') 115 os.remove('./tests/data/clean.jpg')
114 116
117 def test_jpg_nosandbox(self):
118 shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg')
119
120 proc = subprocess.Popen(mat2_binary + ['--show', '--no-sandbox', './tests/data/clean.jpg'],
121 stdout=subprocess.PIPE)
122 stdout, _ = proc.communicate()
123 self.assertIn(b'Comment: Created with GIMP', stdout)
124
125 proc = subprocess.Popen(mat2_binary + ['./tests/data/clean.jpg'],
126 stdout=subprocess.PIPE)
127 stdout, _ = proc.communicate()
128
129 proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.cleaned.jpg'],
130 stdout=subprocess.PIPE)
131 stdout, _ = proc.communicate()
132 self.assertNotIn(b'Comment: Created with GIMP', stdout)
133
134 os.remove('./tests/data/clean.jpg')
135
115 136
116class TestIsSupported(unittest.TestCase): 137class TestIsSupported(unittest.TestCase):
117 def test_pdf(self): 138 def test_pdf(self):
@@ -181,6 +202,7 @@ class TestGetMeta(unittest.TestCase):
181 self.assertIn(b'i am a : various comment', stdout) 202 self.assertIn(b'i am a : various comment', stdout)
182 self.assertIn(b'artist: jvoisin', stdout) 203 self.assertIn(b'artist: jvoisin', stdout)
183 204
205
184class TestControlCharInjection(unittest.TestCase): 206class TestControlCharInjection(unittest.TestCase):
185 def test_jpg(self): 207 def test_jpg(self):
186 proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/control_chars.jpg'], 208 proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/control_chars.jpg'],
@@ -242,6 +264,7 @@ class TestCommandLineParallel(unittest.TestCase):
242 os.remove(path) 264 os.remove(path)
243 os.remove('./tests/data/dirty_%d.docx' % i) 265 os.remove('./tests/data/dirty_%d.docx' % i)
244 266
267
245class TestInplaceCleaning(unittest.TestCase): 268class TestInplaceCleaning(unittest.TestCase):
246 def test_cleaning(self): 269 def test_cleaning(self):
247 shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') 270 shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg')