diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-02 11:13:03 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-02 11:13:03 (GMT) |
commit | 0f5998911c0a39400a42bad781e84eba822fed38 (patch) | |
tree | 0734e865de7015c126a4cfce5c0507f863a89a71 /Lib | |
parent | e95593e9b1498843b403d20f956a0eac9d3b4cc0 (diff) | |
download | cpython-0f5998911c0a39400a42bad781e84eba822fed38.zip cpython-0f5998911c0a39400a42bad781e84eba822fed38.tar.gz cpython-0f5998911c0a39400a42bad781e84eba822fed38.tar.bz2 |
Forward-port PYTHONIOENCODING.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_sys.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 231b460..e1bc98d 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -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) |