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

Method test_ascii

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

Source from the content-addressed store, hash-verified

303 self.assertEqual(overridden_outputs, ['all', 'any', 'tuple', 'list', 'set'])
304
305 def test_ascii(self):
306 self.assertEqual(ascii(''), '\'\'')
307 self.assertEqual(ascii(0), '0')
308 self.assertEqual(ascii(()), '()')
309 self.assertEqual(ascii([]), '[]')
310 self.assertEqual(ascii({}), '{}')
311 a = []
312 a.append(a)
313 self.assertEqual(ascii(a), '[[...]]')
314 a = {}
315 a[0] = a
316 self.assertEqual(ascii(a), '{0: {...}}')
317 # Advanced checks for unicode strings
318 def _check_uni(s):
319 self.assertEqual(ascii(s), repr(s))
320 _check_uni("'")
321 _check_uni('"')
322 _check_uni('"\'')
323 _check_uni('\0')
324 _check_uni('\r\n\t .')
325 # Unprintable non-ASCII characters
326 _check_uni('\x85')
327 _check_uni('\u1fff')
328 _check_uni('\U00012fff')
329 # Lone surrogates
330 _check_uni('\ud800')
331 _check_uni('\udfff')
332 # Issue #9804: surrogates should be joined even for printable
333 # wide characters (UCS-2 builds).
334 self.assertEqual(ascii('\U0001d121'), "'\\U0001d121'")
335 # All together
336 s = "'\0\"\n\r\t abcd\x85é\U00012fff\uD800\U0001D121xxx."
337 self.assertEqual(ascii(s),
338 r"""'\'\x00"\n\r\t abcd\x85\xe9\U00012fff\ud800\U0001d121xxx.'""")
339
340 def test_neg(self):
341 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