Пример #1
0
 def test_string_encoding(self):
     """tests string encoding"""
     strs = Bencoder.encode("announce")
     self.assertEqual(strs, "8:announce")
Пример #2
0
 def test_integer_decode(self):
     """test integer decode"""
     strs = Bencoder.decode("i34e")
     self.assertEqual(strs, 34)
Пример #3
0
 def test_dict_decode(self):
     """test dict decode"""
     strs = Bencoder.decode("d4:abcdli34eee")
     self.assertEqual(strs.get("abcd"), [34])
Пример #4
0
 def test_list_decode(self):
     """tests list decode"""
     strs = Bencoder.decode("li34ee")
     self.assertEqual(strs, [34])
Пример #5
0
 def test_string_decode(self):
     """tests string decode"""
     strs = Bencoder.decode("1:a")
     self.assertEqual(strs, "a")
Пример #6
0
 def test_dict_encoding(self):
     """tests dictionary encoding"""
     strs = Bencoder.encode(dict(a="1"))
     self.assertEqual(strs, "d1:a1:1e")
Пример #7
0
 def test_list_encoding(self):
     """tests list encoding"""
     strs = Bencoder.encode([1, 2])
     self.assertEqual(strs, "li1ei2ee")
Пример #8
0
 def test_integer_encoding(self):
     """tests integer encoding"""
     strs = Bencoder.encode(1)
     self.assertEqual(strs, "i1e")