mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
test_subprocess: test_undecodable_env() is specific to POSIX system
The bug was introduced by the backport of r80421 (r80494).
This commit is contained in:
parent
537bed68ba
commit
097d1b709a
1 changed files with 26 additions and 26 deletions
|
@ -539,32 +539,6 @@ class ProcessTestCase(unittest.TestCase):
|
||||||
if err.errno != 2: # ignore "no such file"
|
if err.errno != 2: # ignore "no such file"
|
||||||
raise
|
raise
|
||||||
|
|
||||||
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()
|
|
||||||
env[key] = value
|
|
||||||
stdout = subprocess.check_output(
|
|
||||||
[sys.executable, "-c", script],
|
|
||||||
env=env)
|
|
||||||
stdout = stdout.rstrip(b'\n\r')
|
|
||||||
self.assertEquals(stdout, value_repr)
|
|
||||||
|
|
||||||
# test bytes
|
|
||||||
key = key.encode("ascii", "surrogateescape")
|
|
||||||
value = value.encode("ascii", "surrogateescape")
|
|
||||||
script = "import os; print(repr(os.getenv(%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)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# POSIX tests
|
# POSIX tests
|
||||||
#
|
#
|
||||||
|
@ -704,6 +678,32 @@ class ProcessTestCase(unittest.TestCase):
|
||||||
p.terminate()
|
p.terminate()
|
||||||
self.assertEqual(p.wait(), -signal.SIGTERM)
|
self.assertEqual(p.wait(), -signal.SIGTERM)
|
||||||
|
|
||||||
|
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()
|
||||||
|
env[key] = value
|
||||||
|
stdout = subprocess.check_output(
|
||||||
|
[sys.executable, "-c", script],
|
||||||
|
env=env)
|
||||||
|
stdout = stdout.rstrip(b'\n\r')
|
||||||
|
self.assertEquals(stdout, value_repr)
|
||||||
|
|
||||||
|
# test bytes
|
||||||
|
key = key.encode("ascii", "surrogateescape")
|
||||||
|
value = value.encode("ascii", "surrogateescape")
|
||||||
|
script = "import os; print(repr(os.getenv(%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)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Windows tests
|
# Windows tests
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue