diff options
author | Philip Jenvey <pjenvey@underboss.org> | 2009-09-29 19:18:11 (GMT) |
---|---|---|
committer | Philip Jenvey <pjenvey@underboss.org> | 2009-09-29 19:18:11 (GMT) |
commit | 7865296ca3e6fb179860c899b3a3a198e6f317c1 (patch) | |
tree | 7b48927f5ff54972e19434e9cdb16c2d1bd8ac6d /Lib/test | |
parent | b4b94ef437d997ad0619345243a112e744f52245 (diff) | |
download | cpython-7865296ca3e6fb179860c899b3a3a198e6f317c1.zip cpython-7865296ca3e6fb179860c899b3a3a198e6f317c1.tar.gz cpython-7865296ca3e6fb179860c899b3a3a198e6f317c1.tar.bz2 |
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
........
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_popen2.py | 26 |
1 files changed, 26 insertions, 0 deletions
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 @@ class Popen2Test(unittest.TestCase): 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 @@ class Popen2Test(unittest.TestCase): 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) |