1
0
Fork 0
mirror of synced 2025-07-03 03:47:20 +02:00

Improve a bit our coverage wrt. torrent files handling

This commit is contained in:
jvoisin 2018-06-10 00:56:55 +02:00
parent 3c56fa3237
commit 87bdcd1a95
2 changed files with 22 additions and 2 deletions

View file

@ -57,6 +57,20 @@ class TestCorruptedFiles(unittest.TestCase):
images.PNGParser('./tests/data/clean.pdf')
os.remove('./tests/data/clean.pdf')
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')
class TestGetMeta(unittest.TestCase):
def test_pdf(self):
p = pdf.PDFParser('./tests/data/dirty.pdf')