(self)
| 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.") |
nothing calls this directly
no test coverage detected