mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Forward-port PYTHONIOENCODING.
This commit is contained in:
parent
e95593e9b1
commit
0f5998911c
4 changed files with 45 additions and 6 deletions
|
|
@ -349,6 +349,26 @@ class SysModuleTest(unittest.TestCase):
|
|||
#self.assert_(r[0][1] > 100, r[0][1])
|
||||
#self.assert_(r[0][2] > 100, r[0][2])
|
||||
|
||||
def test_ioencoding(self):
|
||||
import subprocess,os
|
||||
env = dict(os.environ)
|
||||
|
||||
# Test character: cent sign, encoded as 0x4A (ASCII J) in CP424,
|
||||
# not representable in ASCII.
|
||||
|
||||
env["PYTHONIOENCODING"] = "cp424"
|
||||
p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
|
||||
stdout = subprocess.PIPE, env=env)
|
||||
out = p.stdout.read()
|
||||
self.assertEqual(out, "\xa2\n".encode("cp424"))
|
||||
|
||||
env["PYTHONIOENCODING"] = "ascii:replace"
|
||||
p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
|
||||
stdout = subprocess.PIPE, env=env)
|
||||
out = p.stdout.read().strip()
|
||||
self.assertEqual(out, b'?')
|
||||
|
||||
|
||||
def test_main():
|
||||
test.support.run_unittest(SysModuleTest)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue