Esempio n. 1
0
 def test_nested_dictionary(self):
     adict = {b'foo': 42, b'bar': {b'sketch': b'parrot', b'foobar': 23}}
     encoded_dict = bencode.bencode(adict)
     self.assertEqual(encoded_dict,
                      b"d3:bard6:foobari23e6:sketch6:parrote3:fooi42ee")
Esempio n. 2
0
 def test_roundtrip_decoded(self):
     for plain, encoded in self.knownValues:
         result = bencode.bencode(plain)
         self.assertEqual(plain, bencode.bdecode(result))
Esempio n. 3
0
 def test_sorted_keys_for_dicts(self):
     adict = {b'zoo': 42, b'bar': b'spam'}
     encoded_dict = bencode.bencode(adict)
     self.assertTrue(
         encoded_dict.index(b'zoo') > encoded_dict.index(b'bar'))
Esempio n. 4
0
 def test_bencode_known_values(self):
     for plain, encoded in self.knownValues:
         result = bencode.bencode(plain)
         self.assertEqual(encoded, result)