예제 #1
0
 def _test_roundtrip(self, bs):
     encoded = base62.b2a(bs)
     decoded = base62.a2b(encoded)
     self.assertEqual(decoded, bs)
     self.assertIsInstance(encoded, bytes)
     self.assertIsInstance(bs, bytes)
     self.assertIsInstance(decoded, bytes)
     # Encoded string only uses values from the base62 allowed characters:
     self.assertFalse(set(encoded) - set(base62.chars))
예제 #2
0
 def check_expected(plaintext, encoded):
     result1 = base62.b2a(plaintext)
     self.assertEqual(encoded, result1)
     result2 = base62.a2b(encoded)
     self.assertEqual(plaintext, result2)
예제 #3
0
 def _test_ende(self, bs):
     ascii=base62.b2a(bs)
     bs2=base62.a2b(ascii)
     assert bs2 == bs, "bs2: %s:%s, bs: %s:%s, ascii: %s:%s" % (len(bs2), repr(bs2), len(bs), repr(bs), len(ascii), repr(ascii))