summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2018-10-22 13:42:04 +0200
committerjvoisin2018-10-22 13:42:04 +0200
commit83389a63e9b3e145f527cccf583b30bbe1993f4c (patch)
treecead9df89950e5c8c135043840fcc6d85777959e
parente70ea811c99c16f3382c08153eda573df0825536 (diff)
Test mat2's reliability wrt. corrupted video files
-rw-r--r--libmat2/video.py3
-rw-r--r--tests/test_corrupted_files.py9
-rw-r--r--tests/test_libmat2.py10
3 files changed, 15 insertions, 7 deletions
diff --git a/libmat2/video.py b/libmat2/video.py
index b9f3687..658affa 100644
--- a/libmat2/video.py
+++ b/libmat2/video.py
@@ -43,9 +43,8 @@ class AVIParser(exiftool.ExiftoolParser):
43 43
44 try: 44 try:
45 subprocess.check_call(cmd) 45 subprocess.check_call(cmd)
46 except subprocess.CalledProcessError: # pragma: no cover 46 except subprocess.CalledProcessError:
47 return False 47 return False
48
49 return True 48 return True
50 49
51 50
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py
index 8d7c252..c92f0be 100644
--- a/tests/test_corrupted_files.py
+++ b/tests/test_corrupted_files.py
@@ -5,7 +5,8 @@ import shutil
5import os 5import os
6import logging 6import logging
7 7
8from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless 8from libmat2 import pdf, images, audio, office, parser_factory, torrent
9from libmat2 import harmless, video
9 10
10# No need to logging messages, should something go wrong, 11# No need to logging messages, should something go wrong,
11# the testsuite _will_ fail. 12# the testsuite _will_ fail.
@@ -192,3 +193,9 @@ class TestCorruptedFiles(unittest.TestCase):
192 with self.assertRaises(ValueError): 193 with self.assertRaises(ValueError):
193 images.JPGParser('./tests/data/clean.jpg') 194 images.JPGParser('./tests/data/clean.jpg')
194 os.remove('./tests/data/clean.jpg') 195 os.remove('./tests/data/clean.jpg')
196
197 def test_avi(self):
198 shutil.copy('./tests/data/dirty.torrent', './tests/data/clean.avi')
199 p = video.AVIParser('./tests/data/clean.avi')
200 self.assertFalse(p.remove_all())
201 os.remove('./tests/data/clean.avi')
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 37adc6a..e5cc8a3 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -477,16 +477,18 @@ class TestCleaning(unittest.TestCase):
477 os.remove('./tests/data/clean.cleaned.cleaned.txt') 477 os.remove('./tests/data/clean.cleaned.cleaned.txt')
478 478
479 def test_avi(self): 479 def test_avi(self):
480 try:
481 video._get_ffmpeg_path()
482 except RuntimeError:
483 raise unittest.SkipTest
484
480 shutil.copy('./tests/data/dirty.avi', './tests/data/clean.avi') 485 shutil.copy('./tests/data/dirty.avi', './tests/data/clean.avi')
481 p = video.AVIParser('./tests/data/clean.avi') 486 p = video.AVIParser('./tests/data/clean.avi')
482 487
483 meta = p.get_meta() 488 meta = p.get_meta()
484 self.assertEqual(meta['Software'], 'MEncoder SVN-r33148-4.0.1') 489 self.assertEqual(meta['Software'], 'MEncoder SVN-r33148-4.0.1')
485 490
486 try: 491 ret = p.remove_all()
487 ret = p.remove_all()
488 except RuntimeError:
489 return # this happens if ffmepg is not installed
490 self.assertTrue(ret) 492 self.assertTrue(ret)
491 493
492 p = video.AVIParser('./tests/data/clean.cleaned.avi') 494 p = video.AVIParser('./tests/data/clean.cleaned.avi')