(self)
| 741 | alphabet=binascii.Z85_ALPHABET), b'r\xd8dv') |
| 742 | |
| 743 | def test_base85_alphabet(self): |
| 744 | alphabet = (b'0123456789abcdefghijklmnopqrstuvwxyz' |
| 745 | b'ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#') |
| 746 | data = self.type2test(self.rawdata) |
| 747 | encoded = binascii.b2a_base85(data, alphabet=alphabet) |
| 748 | trans = bytes.maketrans(binascii.BASE85_ALPHABET, alphabet) |
| 749 | expected = binascii.b2a_base85(data).translate(trans) |
| 750 | self.assertEqual(encoded, expected) |
| 751 | self.assertEqual(binascii.a2b_base85(encoded, alphabet=alphabet), self.rawdata) |
| 752 | self.assertEqual(binascii.b2a_base85(data, alphabet=self.type2test(alphabet)), expected) |
| 753 | |
| 754 | data = self.type2test(b'') |
| 755 | self.assertEqual(binascii.b2a_base85(data, alphabet=alphabet), b'') |
| 756 | self.assertEqual(binascii.a2b_base85(data, alphabet=alphabet), b'') |
| 757 | |
| 758 | for func in binascii.b2a_base85, binascii.a2b_base85: |
| 759 | with self.assertRaises(TypeError): |
| 760 | func(data, alphabet=None) |
| 761 | with self.assertRaises(TypeError): |
| 762 | func(data, alphabet=alphabet.decode()) |
| 763 | with self.assertRaises(ValueError): |
| 764 | func(data, alphabet=alphabet[:-1]) |
| 765 | with self.assertRaises(ValueError): |
| 766 | func(data, alphabet=alphabet+b'?') |
| 767 | with self.assertRaises(TypeError): |
| 768 | binascii.a2b_base64(data, alphabet=bytearray(alphabet)) |
| 769 | |
| 770 | def test_base32_valid(self): |
| 771 | # Test base32 with valid data |
nothing calls this directly
no test coverage detected