summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_climat2.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_climat2.py b/tests/test_climat2.py
index e17da86..61f342b 100644
--- a/tests/test_climat2.py
+++ b/tests/test_climat2.py
@@ -2,6 +2,9 @@ import os
2import shutil 2import shutil
3import subprocess 3import subprocess
4import unittest 4import unittest
5import glob
6
7from libmat2 import images, parser_factory
5 8
6 9
7mat2_binary = ['./mat2'] 10mat2_binary = ['./mat2']
@@ -181,3 +184,39 @@ class TestControlCharInjection(unittest.TestCase):
181 stdout=subprocess.PIPE) 184 stdout=subprocess.PIPE)
182 stdout, _ = proc.communicate() 185 stdout, _ = proc.communicate()
183 self.assertIn(b'Comment: GQ\n', stdout) 186 self.assertIn(b'Comment: GQ\n', stdout)
187
188
189class TestCommandLineParallel(unittest.TestCase):
190 iterations = 24
191
192 def test_same(self):
193 for i in range(self.iterations):
194 shutil.copy('./tests/data/dirty.jpg', './tests/data/dirty_%d.jpg' % i)
195
196 proc = subprocess.Popen(mat2_binary + ['./tests/data/dirty_%d.jpg' % i for i in range(self.iterations)],
197 stdout=subprocess.PIPE)
198 stdout, _ = proc.communicate()
199
200 for i in range(self.iterations):
201 path = './tests/data/dirty_%d.jpg' % i
202 p = images.JPGParser('./tests/data/dirty_%d.cleaned.jpg' % i)
203 self.assertEqual(p.get_meta(), {})
204 os.remove('./tests/data/dirty_%d.cleaned.jpg' % i)
205 os.remove(path)
206
207 def test_different(self):
208 shutil.copytree('./tests/data/', './tests/data/parallel')
209
210 proc = subprocess.Popen(mat2_binary + glob.glob('./tests/data/parallel/dirty.*'),
211 stdout=subprocess.PIPE)
212 stdout, _ = proc.communicate()
213
214 for i in glob.glob('./test/data/parallel/dirty.cleaned.*'):
215 p, mime = parser_factory.get_parser(i)
216 self.assertIsNotNone(mime)
217 self.assertIsNotNone(p)
218 p = parser_factory.get_parser(p.output_filename)
219 self.assertEqual(p.get_meta(), {})
220 print('DELET: %s' % i)
221 shutil.rmtree('./tests/data/parallel')
222