diff options
| author | jvoisin | 2020-11-23 19:50:46 +0100 |
|---|---|---|
| committer | jvoisin | 2020-11-30 18:52:07 +0100 |
| commit | 61dce89fbd7759a9d2c19c46930030fd4467374f (patch) | |
| tree | 80ad1da86db63507f4b35acf205a5d2386247403 /tests | |
| parent | 88b7ec2c48a63b158ee69b14dadc506f3359df5f (diff) | |
Raise a ValueError explicitly
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_corrupted_files.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index 8a8cffe..2adf42e 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py | |||
| @@ -65,8 +65,10 @@ class TestCorruptedEmbedded(unittest.TestCase): | |||
| 65 | def test_docx(self): | 65 | def test_docx(self): |
| 66 | shutil.copy('./tests/data/embedded_corrupted.docx', './tests/data/clean.docx') | 66 | shutil.copy('./tests/data/embedded_corrupted.docx', './tests/data/clean.docx') |
| 67 | parser, _ = parser_factory.get_parser('./tests/data/clean.docx') | 67 | parser, _ = parser_factory.get_parser('./tests/data/clean.docx') |
| 68 | self.assertFalse(parser.remove_all()) | 68 | with self.assertRaises(ValueError): |
| 69 | self.assertIsNotNone(parser.get_meta()) | 69 | parser.remove_all() |
| 70 | with self.assertRaises(ValueError): | ||
| 71 | self.assertIsNotNone(parser.get_meta()) | ||
| 70 | os.remove('./tests/data/clean.docx') | 72 | os.remove('./tests/data/clean.docx') |
| 71 | 73 | ||
| 72 | def test_odt(self): | 74 | def test_odt(self): |
| @@ -120,8 +122,8 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 120 | 122 | ||
| 121 | def test_png2(self): | 123 | def test_png2(self): |
| 122 | shutil.copy('./tests/test_libmat2.py', './tests/clean.png') | 124 | shutil.copy('./tests/test_libmat2.py', './tests/clean.png') |
| 123 | parser, _ = parser_factory.get_parser('./tests/clean.png') | 125 | with self.assertRaises(ValueError): |
| 124 | self.assertIsNone(parser) | 126 | parser_factory.get_parser('./tests/clean.png') |
| 125 | os.remove('./tests/clean.png') | 127 | os.remove('./tests/clean.png') |
| 126 | 128 | ||
| 127 | def test_torrent(self): | 129 | def test_torrent(self): |
| @@ -237,10 +239,10 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 237 | zout.write('./tests/data/embedded_corrupted.docx') | 239 | zout.write('./tests/data/embedded_corrupted.docx') |
| 238 | p, mimetype = parser_factory.get_parser('./tests/data/clean.zip') | 240 | p, mimetype = parser_factory.get_parser('./tests/data/clean.zip') |
| 239 | self.assertEqual(mimetype, 'application/zip') | 241 | self.assertEqual(mimetype, 'application/zip') |
| 240 | meta = p.get_meta() | 242 | with self.assertRaises(ValueError): |
| 241 | self.assertEqual(meta['tests/data/dirty.flac']['comments'], 'Thank you for using MAT !') | 243 | p.get_meta() |
| 242 | self.assertEqual(meta['tests/data/dirty.docx']['word/media/image1.png']['Comment'], 'This is a comment, be careful!') | 244 | with self.assertRaises(ValueError): |
| 243 | self.assertFalse(p.remove_all()) | 245 | self.assertFalse(p.remove_all()) |
| 244 | os.remove('./tests/data/clean.zip') | 246 | os.remove('./tests/data/clean.zip') |
| 245 | 247 | ||
| 246 | def test_html(self): | 248 | def test_html(self): |
| @@ -315,10 +317,10 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 315 | zout.addfile(tarinfo, f) | 317 | zout.addfile(tarinfo, f) |
| 316 | p, mimetype = parser_factory.get_parser('./tests/data/clean.tar') | 318 | p, mimetype = parser_factory.get_parser('./tests/data/clean.tar') |
| 317 | self.assertEqual(mimetype, 'application/x-tar') | 319 | self.assertEqual(mimetype, 'application/x-tar') |
| 318 | meta = p.get_meta() | 320 | with self.assertRaises(ValueError): |
| 319 | self.assertEqual(meta['./tests/data/dirty.flac']['comments'], 'Thank you for using MAT !') | 321 | p.get_meta() |
| 320 | self.assertEqual(meta['./tests/data/dirty.docx']['word/media/image1.png']['Comment'], 'This is a comment, be careful!') | 322 | with self.assertRaises(ValueError): |
| 321 | self.assertFalse(p.remove_all()) | 323 | self.assertFalse(p.remove_all()) |
| 322 | os.remove('./tests/data/clean.tar') | 324 | os.remove('./tests/data/clean.tar') |
| 323 | 325 | ||
| 324 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.tar') | 326 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.tar') |
