summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjvoisin2018-06-10 00:56:55 +0200
committerjvoisin2018-06-10 00:56:55 +0200
commit87bdcd1a9501e398bccb03fce606cf6925a75d16 (patch)
tree5b2687defbad65f8720b938fe7a658524228974c /tests
parent3c56fa32375ff8df087d15e8649b661682bbb150 (diff)
Improve a bit our coverage wrt. torrent files handling
Diffstat (limited to 'tests')
-rw-r--r--tests/test_libmat2.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 3d08dea..7deeadc 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -57,6 +57,20 @@ class TestCorruptedFiles(unittest.TestCase):
57 images.PNGParser('./tests/data/clean.pdf') 57 images.PNGParser('./tests/data/clean.pdf')
58 os.remove('./tests/data/clean.pdf') 58 os.remove('./tests/data/clean.pdf')
59 59
60 def test_torrent(self):
61 shutil.copy('./tests/data/dirty.png', './tests/data/clean.torrent')
62 p = torrent.TorrentParser('./tests/data/clean.torrent')
63 self.assertFalse(p.remove_all())
64 expected = {'Unknown meta': 'Unable to parse torrent file "./tests/data/clean.torrent".'}
65 self.assertEqual(p.get_meta(), expected)
66
67 with open("./tests/data/clean.torrent", "a") as f:
68 f.write("trailing garbage")
69 p = torrent.TorrentParser('./tests/data/clean.torrent')
70 self.assertEqual(p.get_meta(), expected)
71
72 os.remove('./tests/data/clean.torrent')
73
60class TestGetMeta(unittest.TestCase): 74class TestGetMeta(unittest.TestCase):
61 def test_pdf(self): 75 def test_pdf(self):
62 p = pdf.PDFParser('./tests/data/dirty.pdf') 76 p = pdf.PDFParser('./tests/data/dirty.pdf')