Example #1
0
 def test_list(self):
     self.assertEqual(bencode.encode([]), 'le')
     self.assertEqual(bencode.encode([
         ['test', 2], [
             ['foo'], [3]
         ]
     ]), 'll4:testi2eell3:fooeli3eeee')
Example #2
0
 def test_dict(self):
     self.assertEqual(bencode.encode({}), 'de')
     self.assertEqual(
         bencode.encode({
             'test': 12,
             'foo': ['bar', {
                 'test': ['again', 12]
             }]
         }), 'd3:fool3:bard4:testl5:againi12eeee4:testi12ee')
Example #3
0
 def test_dict(self):
     self.assertEqual(bencode.encode({}), 'de')
     self.assertEqual(bencode.encode({
         'test': 12,
         'foo': [
             'bar',
             {'test': ['again', 12]}
         ]
     }), 'd3:fool3:bard4:testl5:againi12eeee4:testi12ee')
Example #4
0
 def test_int(self):
     self.assertEqual(bencode.encode(12), 'i12e')
     self.assertEqual(bencode.encode(-12), 'i-12e')
     self.assertEqual(bencode.encode(-0), 'i0e')
Example #5
0
 def test_string(self):
     self.assertEqual(bencode.encode('test'), '4:test')
Example #6
0
 def test_list(self):
     self.assertEqual(bencode.encode([]), 'le')
     self.assertEqual(bencode.encode([['test', 2], [['foo'], [3]]]),
                      'll4:testi2eell3:fooeli3eeee')
Example #7
0
 def test_int(self):
     self.assertEqual(bencode.encode(12), 'i12e')
     self.assertEqual(bencode.encode(-12), 'i-12e')
     self.assertEqual(bencode.encode(-0), 'i0e')
Example #8
0
 def test_string(self):
     self.assertEqual(bencode.encode('test'), '4:test')