MCPcopy Index your code
hub / github.com/python/cpython / test_decodebytes

Method test_decodebytes

Lib/test/test_base64.py:54–73  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

52 self.check_type_errors(base64.encodebytes)
53
54 def test_decodebytes(self):
55 eq = self.assertEqual
56 eq(base64.decodebytes(b"d3d3LnB5dGhvbi5vcmc=\n"), b"www.python.org")
57 eq(base64.decodebytes(b"YQ==\n"), b"a")
58 eq(base64.decodebytes(b"YWI=\n"), b"ab")
59 eq(base64.decodebytes(b"YWJj\n"), b"abc")
60 eq(base64.decodebytes(b"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
61 b"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
62 b"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n"),
63 b"abcdefghijklmnopqrstuvwxyz"
64 b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
65 b"0123456789!@#0^&*();:<>,. []{}")
66 eq(base64.decodebytes(b''), b'')
67 eq(base64.decodebytes(b"QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n"),
68 b"Aladdin:open sesame")
69 # Non-bytes
70 eq(base64.decodebytes(bytearray(b'YWJj\n')), b'abc')
71 eq(base64.decodebytes(memoryview(b'YWJj\n')), b'abc')
72 eq(base64.decodebytes(array('B', b'YWJj\n')), b'abc')
73 self.check_type_errors(base64.decodebytes)
74
75 @hypothesis.given(payload=hypothesis.strategies.binary())
76 @hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')

Callers

nothing calls this directly

Calls 3

check_type_errorsMethod · 0.95
eqFunction · 0.85
arrayClass · 0.85

Tested by

no test coverage detected