Merged revisions 75143 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75143 | philip.jenvey | 2009-09-29 12:10:15 -0700 (Tue, 29 Sep 2009) | 5 lines

  #5329: fix os.popen* regression from 2.5: don't execute commands as a sequence
  through the shell. also document the correct subprocess replacement for this
  case
  patch from Jean-Paul Calderone and Jani Hakala
........
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
index 023871f..2b7c30d 100644
--- a/Lib/test/test_popen2.py
+++ b/Lib/test/test_popen2.py
@@ -78,6 +78,14 @@
 
     def test_os_popen2(self):
         # same test as test_popen2(), but using the os.popen*() API
+        if os.name == 'posix':
+            w, r = os.popen2([self.cmd])
+            self.validate_output(self.teststr, self.expected, r, w)
+
+            w, r = os.popen2(["echo", self.teststr])
+            got = r.read()
+            self.assertEquals(got, self.teststr + "\n")
+
         w, r = os.popen2(self.cmd)
         self.validate_output(self.teststr, self.expected, r, w)
 
@@ -87,9 +95,27 @@
             w, r, e = os.popen3([self.cmd])
             self.validate_output(self.teststr, self.expected, r, w, e)
 
+            w, r, e = os.popen3(["echo", self.teststr])
+            got = r.read()
+            self.assertEquals(got, self.teststr + "\n")
+            got = e.read()
+            self.assertFalse(got, "unexpected %r on stderr" % got)
+
         w, r, e = os.popen3(self.cmd)
         self.validate_output(self.teststr, self.expected, r, w, e)
 
+    def test_os_popen4(self):
+        if os.name == 'posix':
+            w, r = os.popen4([self.cmd])
+            self.validate_output(self.teststr, self.expected, r, w)
+
+            w, r = os.popen4(["echo", self.teststr])
+            got = r.read()
+            self.assertEquals(got, self.teststr + "\n")
+
+        w, r = os.popen4(self.cmd)
+        self.validate_output(self.teststr, self.expected, r, w)
+
 
 def test_main():
     run_unittest(Popen2Test)