summaryrefslogtreecommitdiff
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-01 07:20:46 +0000
committerMartin v. Löwis <martin@v.loewis.de>2008-06-01 07:20:46 +0000
commit99815892f685e9ab20dfdade9c1e8a295139140c (patch)
tree92d2aeaee0a925df71471b296c5fa7ff28a451b8 /Lib/test/test_sys.py
parent7f7ca35f5bf22b698135de62d2179a13f5c94c7f (diff)
downloadcpython-git-99815892f685e9ab20dfdade9c1e8a295139140c.tar.gz
New environment variable PYTHONIOENCODING.
Diffstat (limited to 'Lib/test/test_sys.py')
-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 975795a8ef..a4d8a72c61 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)