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

Method test_ascii

Lib/test/test_builtin.py:296–329  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

294
295
296 def test_ascii(self):
297 self.assertEqual(ascii(''), '\'\'')
298 self.assertEqual(ascii(0), '0')
299 self.assertEqual(ascii(()), '()')
300 self.assertEqual(ascii([]), '[]')
301 self.assertEqual(ascii({}), '{}')
302 a = []
303 a.append(a)
304 self.assertEqual(ascii(a), '[[...]]')
305 a = {}
306 a[0] = a
307 self.assertEqual(ascii(a), '{0: {...}}')
308 # Advanced checks for unicode strings
309 def _check_uni(s):
310 self.assertEqual(ascii(s), repr(s))
311 _check_uni("'")
312 _check_uni('"')
313 _check_uni('"\'')
314 _check_uni('\0')
315 _check_uni('\r\n\t .')
316 # Unprintable non-ASCII characters
317 _check_uni('\x85')
318 _check_uni('\u1fff')
319 _check_uni('\U00012fff')
320 # Lone surrogates
321 _check_uni('\ud800')
322 _check_uni('\udfff')
323 # Issue #9804: surrogates should be joined even for printable
324 # wide characters (UCS-2 builds).
325 self.assertEqual(ascii('\U0001d121'), "'\\U0001d121'")
326 # All together
327 s = "'\0\"\n\r\t abcd\x85é\U00012fff\uD800\U0001D121xxx."
328 self.assertEqual(ascii(s),
329 r"""'\'\x00"\n\r\t abcd\x85\xe9\U00012fff\ud800\U0001d121xxx.'""")
330
331 def test_neg(self):
332 x = -sys.maxsize-1

Callers

nothing calls this directly

Calls 3

asciiFunction · 0.85
assertEqualMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected