[Python-checkins] cpython (merge default -> default): Merge heads
antoine.pitrou
python-checkins at python.org
Sun Nov 11 19:42:09 CET 2012
http://hg.python.org/cpython/rev/3fa77d4d65b3
changeset: 80399:3fa77d4d65b3
parent: 80396:9e80ea48ff39
parent: 80392:c971687e5c66
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sun Nov 11 19:41:09 2012 +0100
summary:
Merge heads
files:
Lib/test/test_subprocess.py | 39 ++++++++++++------------
1 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1189,23 +1189,15 @@
self.fail("Exception raised by preexec_fn did not make it "
"to the parent process.")
- @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.")
- def test_preexec_errpipe_does_not_double_close_pipes(self):
- """Issue16140: Don't double close pipes on preexec error."""
- class SafeConstructorPopen(subprocess.Popen):
- def __init__(self):
- pass # Do nothing so we can modify the instance for testing.
- def RealPopen(self, *args, **kwargs):
- subprocess.Popen.__init__(self, *args, **kwargs)
- def raise_it():
- raise subprocess.SubprocessError(
- "force the _execute_child() errpipe_data path.")
+ class _TestExecuteChildPopen(subprocess.Popen):
+ """Used to test behavior at the end of _execute_child."""
+ def __init__(self, testcase, *args, **kwargs):
+ self._testcase = testcase
+ subprocess.Popen.__init__(self, *args, **kwargs)
- p = SafeConstructorPopen()
-
- def _test_fds_execute_child_wrapper(*args, **kwargs):
+ def _execute_child(self, *args, **kwargs):
try:
- subprocess.Popen._execute_child(p, *args, **kwargs)
+ subprocess.Popen._execute_child(self, *args, **kwargs)
finally:
# Open a bunch of file descriptors and verify that
# none of them are the same as the ones the Popen
@@ -1214,17 +1206,24 @@
for _ in range(8)]
try:
for fd in devzero_fds:
- self.assertNotIn(fd, (
- p.stdin.fileno(), p.stdout.fileno(),
- p.stderr.fileno()),
+ self._testcase.assertNotIn(
+ fd, (self.stdin.fileno(), self.stdout.fileno(),
+ self.stderr.fileno()),
msg="At least one fd was closed early.")
finally:
map(os.close, devzero_fds)
- p._execute_child = _test_fds_execute_child_wrapper
+ @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.")
+ def test_preexec_errpipe_does_not_double_close_pipes(self):
+ """Issue16140: Don't double close pipes on preexec error."""
+
+ def raise_it():
+ raise subprocess.SubprocessError(
+ "force the _execute_child() errpipe_data path.")
with self.assertRaises(subprocess.SubprocessError):
- p.RealPopen([sys.executable, "-c", "pass"],
+ self._TestExecuteChildPopen(
+ self, [sys.executable, "-c", "pass"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, preexec_fn=raise_it)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list