From b02d72887afd4498b03cdd767ca46676fb150622 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 6 May 2018 21:58:31 +0200 Subject: Test for faulty files, and document how MAT2 is behaving wrt. them --- tests/test_libmat2.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 1950444..17afaf4 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py @@ -16,6 +16,18 @@ class TestParserFactory(unittest.TestCase): self.assertEqual(mimetype, 'audio/mpeg') self.assertEqual(parser.__class__, audio.MP3Parser) +class TestCorruptedFiles(unittest.TestCase): + def test_pdf(self): + shutil.copy('./tests/data/dirty.png', './tests/data/clean.png') + with self.assertRaises(ValueError): + pdf.PDFParser('./tests/data/clean.png') + os.remove('./tests/data/clean.png') + + def test_png(self): + shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf') + with self.assertRaises(ValueError): + images.PNGParser('./tests/data/clean.pdf') + os.remove('./tests/data/clean.pdf') class TestGetMeta(unittest.TestCase): def test_pdf(self): -- cgit v1.3