diff options
| author | jvoisin | 2018-06-22 20:38:29 +0200 |
|---|---|---|
| committer | jvoisin | 2018-06-22 20:38:29 +0200 |
| commit | b4ef0c9622a0741bcfa0da1f65d9082251fb4107 (patch) | |
| tree | 37d3a70ef17f14267e8a8bbe88f97589f15848df /tests | |
| parent | dfccf79f22a9d0dd2f0d9015dbe0cb398b01078c (diff) | |
Improve reliability against corrupted image files
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_libmat2.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index e1d949d..0df333d 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -87,13 +87,25 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 87 | f.write("trailing garbage") | 87 | f.write("trailing garbage") |
| 88 | p = torrent.TorrentParser('./tests/data/clean.torrent') | 88 | p = torrent.TorrentParser('./tests/data/clean.torrent') |
| 89 | self.assertEqual(p.get_meta(), expected) | 89 | self.assertEqual(p.get_meta(), expected) |
| 90 | |||
| 91 | os.remove('./tests/data/clean.torrent') | 90 | os.remove('./tests/data/clean.torrent') |
| 92 | 91 | ||
| 93 | def test_odg(self): | 92 | def test_odg(self): |
| 94 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.odg') | 93 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.odg') |
| 95 | with self.assertRaises(ValueError): | 94 | with self.assertRaises(ValueError): |
| 96 | office.LibreOfficeParser('./tests/data/clean.odg') | 95 | office.LibreOfficeParser('./tests/data/clean.odg') |
| 96 | os.remove('./tests/data/clean.odg') | ||
| 97 | |||
| 98 | def test_bmp(self): | ||
| 99 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.bmp') | ||
| 100 | with self.assertRaises(ValueError): | ||
| 101 | p = images.BMPParser('./tests/data/clean.bmp') | ||
| 102 | os.remove('./tests/data/clean.bmp') | ||
| 103 | |||
| 104 | def test_docx(self): | ||
| 105 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.docx') | ||
| 106 | with self.assertRaises(ValueError): | ||
| 107 | p = office.MSOfficeParser('./tests/data/clean.docx') | ||
| 108 | os.remove('./tests/data/clean.docx') | ||
| 97 | 109 | ||
| 98 | class TestGetMeta(unittest.TestCase): | 110 | class TestGetMeta(unittest.TestCase): |
| 99 | def test_pdf(self): | 111 | def test_pdf(self): |
| @@ -123,7 +135,7 @@ class TestGetMeta(unittest.TestCase): | |||
| 123 | self.assertEqual(meta['Comment'], 'Created with GIMP') | 135 | self.assertEqual(meta['Comment'], 'Created with GIMP') |
| 124 | 136 | ||
| 125 | def test_tiff(self): | 137 | def test_tiff(self): |
| 126 | p = images.JPGParser('./tests/data/dirty.tiff') | 138 | p = images.TiffParser('./tests/data/dirty.tiff') |
| 127 | meta = p.get_meta() | 139 | meta = p.get_meta() |
| 128 | self.assertEqual(meta['Make'], 'OLYMPUS IMAGING CORP.') | 140 | self.assertEqual(meta['Make'], 'OLYMPUS IMAGING CORP.') |
| 129 | self.assertEqual(meta['Model'], 'C7070WZ') | 141 | self.assertEqual(meta['Model'], 'C7070WZ') |
