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

Method test_ascii

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected