From b5fcddd6a68b7e18d1e5521e7363046ca0e68667 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 8 Jul 2018 13:47:00 +0200 Subject: Simplify how torrent files are handled - Rework the testsuite wrt. torrent - fail at parser's instantiation on corrupted torrent, instead of during `get_meta` or `remove_all` call --- tests/test_corrupted_files.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests/test_corrupted_files.py') diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index bc5b9d0..776b0e9 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py @@ -46,15 +46,14 @@ class TestCorruptedFiles(unittest.TestCase): 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 self.assertRaises(ValueError): + torrent.TorrentParser('./tests/data/clean.torrent') 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) + with self.assertRaises(ValueError): + torrent.TorrentParser('./tests/data/clean.torrent') + os.remove('./tests/data/clean.torrent') def test_odg(self): -- cgit v1.3