diff options
| author | jvoisin | 2018-07-08 13:47:00 +0200 |
|---|---|---|
| committer | jvoisin | 2018-07-08 13:49:11 +0200 |
| commit | b5fcddd6a68b7e18d1e5521e7363046ca0e68667 (patch) | |
| tree | aff042f60c0dcb5d8c3e19e815616b8af7ec0d05 /tests/test_corrupted_files.py | |
| parent | 7ea362d908314bacd980151365148e7aac1cf994 (diff) | |
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
Diffstat (limited to 'tests/test_corrupted_files.py')
| -rw-r--r-- | tests/test_corrupted_files.py | 11 |
1 files changed, 5 insertions, 6 deletions
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): | |||
| 46 | 46 | ||
| 47 | def test_torrent(self): | 47 | def test_torrent(self): |
| 48 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.torrent') | 48 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.torrent') |
| 49 | p = torrent.TorrentParser('./tests/data/clean.torrent') | 49 | with self.assertRaises(ValueError): |
| 50 | self.assertFalse(p.remove_all()) | 50 | torrent.TorrentParser('./tests/data/clean.torrent') |
| 51 | expected = {'Unknown meta': 'Unable to parse torrent file "./tests/data/clean.torrent".'} | ||
| 52 | self.assertEqual(p.get_meta(), expected) | ||
| 53 | 51 | ||
| 54 | with open("./tests/data/clean.torrent", "a") as f: | 52 | with open("./tests/data/clean.torrent", "a") as f: |
| 55 | f.write("trailing garbage") | 53 | f.write("trailing garbage") |
| 56 | p = torrent.TorrentParser('./tests/data/clean.torrent') | 54 | with self.assertRaises(ValueError): |
| 57 | self.assertEqual(p.get_meta(), expected) | 55 | torrent.TorrentParser('./tests/data/clean.torrent') |
| 56 | |||
| 58 | os.remove('./tests/data/clean.torrent') | 57 | os.remove('./tests/data/clean.torrent') |
| 59 | 58 | ||
| 60 | def test_odg(self): | 59 | def test_odg(self): |
