Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_subprocess.py @ 61693:cf74ec3e1f82
Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
subprocess.Popen() and os._execvpe() support bytes program name. Add
os.supports_bytes_environ flag: True if the native OS type of the environment
is bytes (eg. False on Windows).
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Tue, 18 May 2010 17:17:23 +0000 |
| parents | 7e5bdf59a487 |
| children | 441491572fce |
line wrap: on
line diff
--- a/Lib/test/test_subprocess.py Tue May 18 14:15:20 2010 +0000 +++ b/Lib/test/test_subprocess.py Tue May 18 17:17:23 2010 +0000 @@ -825,6 +825,27 @@ stdout = stdout.rstrip(b'\n\r') self.assertEquals(stdout.decode('ascii'), repr(value)) + def test_bytes_program(self): + abs_program = os.fsencode(sys.executable) + path, program = os.path.split(sys.executable) + program = os.fsencode(program) + + # absolute bytes path + exitcode = subprocess.call([abs_program, "-c", "pass"]) + self.assertEquals(exitcode, 0) + + # bytes program, unicode PATH + env = os.environ.copy() + env["PATH"] = path + exitcode = subprocess.call([program, "-c", "pass"], env=env) + self.assertEquals(exitcode, 0) + + # bytes program, bytes PATH + envb = os.environb.copy() + envb[b"PATH"] = os.fsencode(path) + exitcode = subprocess.call([program, "-c", "pass"], env=envb) + self.assertEquals(exitcode, 0) + @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase):
