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

Method test_ascii

Lib/test/test_codecs.py:927–951  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

925 encoding = "utf-7"
926
927 def test_ascii(self):
928 # Set D (directly encoded characters)
929 set_d = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
930 'abcdefghijklmnopqrstuvwxyz'
931 '0123456789'
932 '\'(),-./:?')
933 self.assertEqual(set_d.encode(self.encoding), set_d.encode('ascii'))
934 self.assertEqual(set_d.encode('ascii').decode(self.encoding), set_d)
935 # Set O (optional direct characters)
936 set_o = ' !"#$%&*;<=>@[]^_`{|}'
937 self.assertEqual(set_o.encode(self.encoding), set_o.encode('ascii'))
938 self.assertEqual(set_o.encode('ascii').decode(self.encoding), set_o)
939 # +
940 self.assertEqual('a+b'.encode(self.encoding), b'a+-b')
941 self.assertEqual(b'a+-b'.decode(self.encoding), 'a+b')
942 # White spaces
943 ws = ' \t\n\r'
944 self.assertEqual(ws.encode(self.encoding), ws.encode('ascii'))
945 self.assertEqual(ws.encode('ascii').decode(self.encoding), ws)
946 # Other ASCII characters
947 other_ascii = ''.join(sorted(set(bytes(range(0x80)).decode()) -
948 set(set_d + set_o + '+' + ws)))
949 self.assertEqual(other_ascii.encode(self.encoding),
950 b'+AAAAAQACAAMABAAFAAYABwAIAAsADAAOAA8AEAARABIAEwAU'
951 b'ABUAFgAXABgAGQAaABsAHAAdAB4AHwBcAH4Afw-')
952
953 def test_partial(self):
954 self.check_partial(

Callers

nothing calls this directly

Calls 5

setFunction · 0.85
assertEqualMethod · 0.45
encodeMethod · 0.45
decodeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected