[Python-checkins] r82866 - python/branches/import_unicode/Lib/test/test_subprocess.py
victor.stinner
python-checkins at python.org
Wed Jul 14 01:47:57 CEST 2010
Author: victor.stinner
Date: Wed Jul 14 01:47:57 2010
New Revision: 82866
Log:
fix test_subprocess for non-ascii path but ascii locale
* write shell script using errors="surrogateescape" (PEP 383)
* skip test_bytes_program() if python is not installed
Modified:
python/branches/import_unicode/Lib/test/test_subprocess.py
Modified: python/branches/import_unicode/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/import_unicode/Lib/test/test_subprocess.py (original)
+++ python/branches/import_unicode/Lib/test/test_subprocess.py Wed Jul 14 01:47:57 2010
@@ -698,7 +698,7 @@
# args is a string
fd, fname = mkstemp()
# reopen in text mode
- with open(fd, "w") as fobj:
+ with open(fd, "w", errors="surrogateescape") as fobj:
fobj.write("#!/bin/sh\n")
fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
sys.executable)
@@ -741,7 +741,7 @@
# call() function with string argument on UNIX
fd, fname = mkstemp()
# reopen in text mode
- with open(fd, "w") as fobj:
+ with open(fd, "w", errors="surrogateescape") as fobj:
fobj.write("#!/bin/sh\n")
fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
sys.executable)
@@ -834,15 +834,15 @@
stdout = stdout.rstrip(b'\n\r')
self.assertEquals(stdout.decode('ascii'), repr(value))
+ def test_absolute_bytes_program(self):
+ exitcode = subprocess.call([os.fsencode(sys.executable), "-c", "pass"])
+ self.assertEquals(exitcode, 0)
+
+ @unittest.skipIf(sysconfig.is_python_build(), "need an installed Python")
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
More information about the Python-checkins
mailing list