From 74f2d50433a831787fe7ab791748c8efa854ada2 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 22 Jun 2018 21:16:55 +0200 Subject: Split the testsuite a bit and add more tests --- tests/test_libmat2.py | 66 --------------------------------------------------- 1 file changed, 66 deletions(-) (limited to 'tests/test_libmat2.py') diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 0df333d..b34e7a4 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py @@ -40,72 +40,6 @@ class TestUnsupportedEmbeddedFiles(unittest.TestCase): self.assertFalse(p.remove_all()) os.remove('./tests/data/clean.docx') -class TestUnsupportedFiles(unittest.TestCase): - def test_pdf(self): - shutil.copy('./tests/test_libmat2.py', './tests/clean.py') - parser, mimetype = parser_factory.get_parser('./tests/data/clean.py') - self.assertEqual(mimetype, 'text/x-python') - self.assertEqual(parser, None) - os.remove('./tests/clean.py') - -class TestExplicitelyUnsupportedFiles(unittest.TestCase): - def test_pdf(self): - shutil.copy('./tests/test_libmat2.py', './tests/clean.txt') - parser, mimetype = parser_factory.get_parser('./tests/data/clean.txt') - self.assertEqual(mimetype, 'text/plain') - self.assertEqual(parser, None) - os.remove('./tests/clean.txt') - - -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') - - def test_png2(self): - shutil.copy('./tests/test_libmat2.py', './tests/clean.png') - parser, mimetype = parser_factory.get_parser('./tests/clean.png') - self.assertIsNone(parser) - os.remove('./tests/clean.png') - - def test_torrent(self): - shutil.copy('./tests/data/dirty.png', './tests/data/clean.torrent') - p = torrent.TorrentParser('./tests/data/clean.torrent') - self.assertFalse(p.remove_all()) - expected = {'Unknown meta': 'Unable to parse torrent file "./tests/data/clean.torrent".'} - self.assertEqual(p.get_meta(), expected) - - with open("./tests/data/clean.torrent", "a") as f: - f.write("trailing garbage") - p = torrent.TorrentParser('./tests/data/clean.torrent') - self.assertEqual(p.get_meta(), expected) - os.remove('./tests/data/clean.torrent') - - def test_odg(self): - shutil.copy('./tests/data/dirty.png', './tests/data/clean.odg') - with self.assertRaises(ValueError): - office.LibreOfficeParser('./tests/data/clean.odg') - os.remove('./tests/data/clean.odg') - - def test_bmp(self): - shutil.copy('./tests/data/dirty.png', './tests/data/clean.bmp') - with self.assertRaises(ValueError): - p = images.BMPParser('./tests/data/clean.bmp') - os.remove('./tests/data/clean.bmp') - - def test_docx(self): - shutil.copy('./tests/data/dirty.png', './tests/data/clean.docx') - with self.assertRaises(ValueError): - p = office.MSOfficeParser('./tests/data/clean.docx') - os.remove('./tests/data/clean.docx') class TestGetMeta(unittest.TestCase): def test_pdf(self): -- cgit v1.3