summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorPeter Astrand <astrand@lysator.liu.se>2005-03-03 20:24:28 (GMT)
committerPeter Astrand <astrand@lysator.liu.se>2005-03-03 20:24:28 (GMT)
commitcbac93c2293dd2cc6f10b31e91eaa1a502822704 (patch)
tree83a78c48805b796f7ad1505aeb5ee54da57cbaf8 /Lib/test/test_subprocess.py
parentb098fd7f891627693e304b415354253348418614 (diff)
downloadcpython-cbac93c2293dd2cc6f10b31e91eaa1a502822704.zip
cpython-cbac93c2293dd2cc6f10b31e91eaa1a502822704.tar.gz
cpython-cbac93c2293dd2cc6f10b31e91eaa1a502822704.tar.bz2
Added three more testcases: Using communicate with only one of
stdin/stdout/stderr redirected.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 52f4d47..e8415cd 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -248,6 +248,29 @@ class ProcessTestCase(unittest.TestCase):
env=newenv)
self.assertEqual(p.stdout.read(), "orange")
+ def test_communicate_stdin(self):
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys; sys.exit(sys.stdin.read() == "pear")'],
+ stdin=subprocess.PIPE)
+ p.communicate("pear")
+ self.assertEqual(p.returncode, 1)
+
+ def test_communicate_stdout(self):
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys; sys.stdout.write("pineapple")'],
+ stdout=subprocess.PIPE)
+ (stdout, stderr) = p.communicate()
+ self.assertEqual(stdout, "pineapple")
+ self.assertEqual(stderr, None)
+
+ def test_communicate_stderr(self):
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys; sys.stderr.write("pineapple")'],
+ stderr=subprocess.PIPE)
+ (stdout, stderr) = p.communicate()
+ self.assertEqual(stdout, None)
+ self.assertEqual(stderr, "pineapple")
+
def test_communicate(self):
p = subprocess.Popen([sys.executable, "-c",
'import sys,os;' \