summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-06 22:05:07 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-06 22:05:07 (GMT)
commit84ae1180063a6f9fc39c22a5977b49aaac8c3b3c (patch)
tree188bac431d36a612b99a98fc263a0baa96ce67c2 /Lib/test/test_subprocess.py
parentd930b63583a8dc1ece9407652636209a3d396149 (diff)
downloadcpython-84ae1180063a6f9fc39c22a5977b49aaac8c3b3c.zip
cpython-84ae1180063a6f9fc39c22a5977b49aaac8c3b3c.tar.gz
cpython-84ae1180063a6f9fc39c22a5977b49aaac8c3b3c.tar.bz2
Issue #8603: Create a bytes version of os.environ for Unix
Create os.environb mapping and os.getenvb() function, os.unsetenv() encodes str argument to the file system encoding with the surrogateescape error handler (instead of utf8/strict) and accepts bytes, and posix.environ keys and values are bytes.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index be163fc..eb96706 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -803,8 +803,6 @@ class POSIXProcessTestCase(BaseTestCase):
def test_undecodable_env(self):
for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')):
- value_repr = repr(value).encode("ascii")
-
# test str with surrogates
script = "import os; print(repr(os.getenv(%s)))" % repr(key)
env = os.environ.copy()
@@ -813,19 +811,19 @@ class POSIXProcessTestCase(BaseTestCase):
[sys.executable, "-c", script],
env=env)
stdout = stdout.rstrip(b'\n\r')
- self.assertEquals(stdout, value_repr)
+ self.assertEquals(stdout.decode('ascii'), repr(value))
# test bytes
key = key.encode("ascii", "surrogateescape")
value = value.encode("ascii", "surrogateescape")
- script = "import os; print(repr(os.getenv(%s)))" % repr(key)
+ script = "import os; print(repr(os.getenvb(%s)))" % repr(key)
env = os.environ.copy()
env[key] = value
stdout = subprocess.check_output(
[sys.executable, "-c", script],
env=env)
stdout = stdout.rstrip(b'\n\r')
- self.assertEquals(stdout, value_repr)
+ self.assertEquals(stdout.decode('ascii'), repr(value))
@unittest.skipUnless(mswindows, "Windows specific tests")