From b8fec119da901b84496673dfc9768a3412caa597 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 6 Apr 2016 19:05:08 -0400 Subject: [PATCH 1/2] add test to make sure the file_storage object is iterable in the python bindings --- bindings/python/test.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bindings/python/test.py b/bindings/python/test.py index 31cc02c36..635b652db 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -45,6 +45,20 @@ class test_torrent_info(unittest.TestCase): self.assertTrue(len(ti.metadata()) != 0) self.assertTrue(len(ti.hash_for_piece(0)) != 0) + def test_iterable_files(self): + 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): def test_alert(self): From a9952a38cff720b3ce6fe0c0c26ca3aed1469833 Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 7 Apr 2016 02:23:21 -0400 Subject: [PATCH 2/2] fix python test --- bindings/python/test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bindings/python/test.py b/bindings/python/test.py index 635b652db..3a29a06cf 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -46,6 +46,11 @@ class test_torrent_info(unittest.TestCase): 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()