diff options
| author | jvoisin | 2018-10-22 13:42:04 +0200 |
|---|---|---|
| committer | jvoisin | 2018-10-22 13:42:04 +0200 |
| commit | 83389a63e9b3e145f527cccf583b30bbe1993f4c (patch) | |
| tree | cead9df89950e5c8c135043840fcc6d85777959e /tests | |
| parent | e70ea811c99c16f3382c08153eda573df0825536 (diff) | |
Test mat2's reliability wrt. corrupted video files
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_corrupted_files.py | 9 | ||||
| -rw-r--r-- | tests/test_libmat2.py | 10 |
2 files changed, 14 insertions, 5 deletions
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 | |||
| 5 | import os | 5 | import os |
| 6 | import logging | 6 | import logging |
| 7 | 7 | ||
| 8 | from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless | 8 | from libmat2 import pdf, images, audio, office, parser_factory, torrent |
| 9 | from 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') |
