Merge pull request #595 from arvidn/py-terable-files-1.1

add test to make sure the file_storage object is iterable in the python bindings
This commit is contained in:
Arvid Norberg 2016-04-07 14:38:29 -04:00
commit 0220016311
1 changed files with 19 additions and 0 deletions

View File

@ -45,6 +45,25 @@ class test_torrent_info(unittest.TestCase):
self.assertTrue(len(ti.metadata()) != 0) self.assertTrue(len(ti.metadata()) != 0)
self.assertTrue(len(ti.hash_for_piece(0)) != 0) self.assertTrue(len(ti.hash_for_piece(0)) != 0)
def test_iterable_files(self):
# this detects whether libtorrent was built with deprecated APIs
# the file_strage object is only iterable for backwards compatibility
if not hasattr(lt, 'version'): return
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories})
ti = lt.torrent_info('url_seed_multi.torrent');
files = ti.files()
idx = 0
expected = ['bar.txt', 'var.txt']
for f in files:
print f.path
self.assertEqual(os.path.split(f.path)[1], expected[idx])
self.assertEqual(os.path.split(f.path)[0], 'temp/foo')
idx += 1
class test_alerts(unittest.TestCase): class test_alerts(unittest.TestCase):
def test_alert(self): def test_alert(self):