MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_encodebytes

Method test_encodebytes

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

Source from the content-addressed store, hash-verified

27 self.assertRaises(TypeError, f, int_data)
28
29 def test_encodebytes(self):
30 eq = self.assertEqual
31 eq(base64.encodebytes(b"www.python.org"), b"d3d3LnB5dGhvbi5vcmc=\n")
32 eq(base64.encodebytes(b"a"), b"YQ==\n")
33 eq(base64.encodebytes(b"ab"), b"YWI=\n")
34 eq(base64.encodebytes(b"abc"), b"YWJj\n")
35 eq(base64.encodebytes(b""), b"")
36 eq(base64.encodebytes(b"abcdefghijklmnopqrstuvwxyz"
37 b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
38 b"0123456789!@#0^&*();:<>,. []{}"),
39 b"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
40 b"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
41 b"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n")
42 eq(base64.encodebytes(b"Aladdin:open sesame"),
43 b"QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n")
44 # Non-bytes
45 eq(base64.encodebytes(bytearray(b'abc')), b'YWJj\n')
46 eq(base64.encodebytes(memoryview(b'abc')), b'YWJj\n')
47 eq(base64.encodebytes(array('B', b'abc')), b'YWJj\n')
48 self.check_type_errors(base64.encodebytes)
49
50 def test_decodebytes(self):
51 eq = self.assertEqual

Callers

nothing calls this directly

Calls 3

check_type_errorsMethod · 0.95
arrayClass · 0.85
eqFunction · 0.50

Tested by

no test coverage detected