summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-01 07:20:46 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-01 07:20:46 (GMT)
commit99815892f685e9ab20dfdade9c1e8a295139140c (patch)
tree92d2aeaee0a925df71471b296c5fa7ff28a451b8 /Lib/test
parent7f7ca35f5bf22b698135de62d2179a13f5c94c7f (diff)
downloadcpython-99815892f685e9ab20dfdade9c1e8a295139140c.zip
cpython-99815892f685e9ab20dfdade9c1e8a295139140c.tar.gz
cpython-99815892f685e9ab20dfdade9c1e8a295139140c.tar.bz2
New environment variable PYTHONIOENCODING.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_sys.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 975795a..a4d8a72 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -385,6 +385,26 @@ class SysModuleTest(unittest.TestCase):
## self.assert_(r[0][2] > 100, r[0][2])
## self.assert_(r[1][2] > 100, r[1][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 unichr(0xa2)'],
+ stdout = subprocess.PIPE, env=env)
+ out = p.stdout.read().strip()
+ self.assertEqual(out, unichr(0xa2).encode("cp424"))
+
+ env["PYTHONIOENCODING"] = "ascii:replace"
+ p = subprocess.Popen([sys.executable, "-c", 'print unichr(0xa2)'],
+ stdout = subprocess.PIPE, env=env)
+ out = p.stdout.read().strip()
+ self.assertEqual(out, '?')
+
+
def test_main():
test.test_support.run_unittest(SysModuleTest)