[Python-checkins]
python/dist/src/Lib/test test_subprocess.py, 1.17, 1.18
astrand at users.sourceforge.net
astrand at users.sourceforge.net
Thu Mar 3 21:24:30 CET 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2316
Modified Files:
test_subprocess.py
Log Message:
Added three more testcases: Using communicate with only one of
stdin/stdout/stderr redirected.
Index: test_subprocess.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- test_subprocess.py 1 Jan 2005 09:36:35 -0000 1.17
+++ test_subprocess.py 3 Mar 2005 20:24:28 -0000 1.18
@@ -248,6 +248,29 @@
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;' \
More information about the Python-checkins
mailing list