def test_nested_list(self): """ Test that a nested list is decoded correctly. """ self.n = bencode.decode_list("lli1ei2eeli3ei4eee") self.assertEquals(self.n, [[1, 2], [3, 4]])
def test_empty_list(self): """ Test that an empty list is decoded correctly. """ self.n = bencode.decode_list("le") self.assertEquals(self.n, [])
def test_longer_list(self): """ Test that a longer list is decoded correctly. """ self.n = bencode.decode_list("li1ei2ei3ee") self.assertEquals(self.n, [1, 2, 3])
def test_mixed_list(self): """ Test that a mixed list is decoded correctly. """ self.n = bencode.decode_list("li1e3:onee") self.assertEquals(self.n, [1, "one"])
def test_simple_list(self): """ Test that a one item list is decoded correctly. """ self.n = bencode.decode_list("li1ee") self.assertEquals(self.n, [1])
def test_decode_list(self): bstr = b'l4:spam4:eggse' # r, de_index = decode_list(bstr, 0) # self.assertListEqual([b'spam',b'eggs'], r) # self.assertEquals(14, de_index) self.assertEqual(([b'spam', b'eggs'], 14), decode_list(bstr, 0))
def test_multi_dimentional_list(self): exp = 'l4:spamli4e4:eggsi-23ee5:helloe' lst = ['spam', [4, 'eggs', -23], 'hello'] self.assertEqual(lst, b.decode_list(exp))
def test_one_dimentional_list(self): exp = 'l4:spam4:eggsi23ee' lst = ['spam', 'eggs', 23] self.assertEqual(b.decode_list(exp), lst)