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

Method test_displayhook_unencodable

Lib/test/test_cmd_line.py:444–460  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

442 self.assertEqual(out1, out2)
443
444 def test_displayhook_unencodable(self):
445 for encoding in ('ascii', 'latin-1', 'utf-8'):
446 env = os.environ.copy()
447 env['PYTHONIOENCODING'] = encoding
448 p = subprocess.Popen(
449 [sys.executable, '-i'],
450 stdin=subprocess.PIPE,
451 stdout=subprocess.PIPE,
452 stderr=subprocess.STDOUT,
453 env=env)
454 # non-ascii, surrogate, non-BMP printable, non-BMP unprintable
455 text = "a=\xe9 b=\uDC80 c=\U00010000 d=\U0010FFFF"
456 p.stdin.write(ascii(text).encode('ascii') + b"\n")
457 p.stdin.write(b'exit()\n')
458 data = kill_python(p)
459 escaped = repr(text).encode(encoding, 'backslashreplace')
460 self.assertIn(escaped, data)
461
462 def check_input(self, code, expected):
463 with tempfile.NamedTemporaryFile("wb+") as stdin:

Callers

nothing calls this directly

Calls 6

kill_pythonFunction · 0.90
asciiFunction · 0.85
assertInMethod · 0.80
copyMethod · 0.45
writeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected