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

Method test_osx_android_utf8

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

Source from the content-addressed store, hash-verified

345 @unittest.skipUnless((sys.platform == 'darwin' or
346 support.is_android), 'test specific to Mac OS X and Android')
347 def test_osx_android_utf8(self):
348 text = 'e:\xe9, euro:\u20ac, non-bmp:\U0010ffff'.encode('utf-8')
349 code = "import sys; print(ascii(sys.argv[1]))"
350
351 decoded = text.decode('utf-8', 'surrogateescape')
352 expected = ascii(decoded).encode('ascii') + b'\n'
353
354 env = os.environ.copy()
355 # C locale gives ASCII locale encoding, but Python uses UTF-8
356 # to parse the command line arguments on Mac OS X and Android.
357 env['LC_ALL'] = 'C'
358
359 p = subprocess.Popen(
360 (sys.executable, "-c", code, text),
361 stdout=subprocess.PIPE,
362 env=env)
363 stdout, stderr = p.communicate()
364 self.assertEqual(stdout, expected)
365 self.assertEqual(p.returncode, 0)
366
367 @unittest.skipIf(os.environ.get("PYTHONUNBUFFERED", "0") != "0",
368 "Python stdio buffering is disabled.")

Callers

nothing calls this directly

Calls 6

communicateMethod · 0.95
asciiFunction · 0.85
encodeMethod · 0.45
decodeMethod · 0.45
copyMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected