diff options
author | Philip Jenvey <pjenvey@underboss.org> | 2009-09-29 19:10:15 (GMT) |
---|---|---|
committer | Philip Jenvey <pjenvey@underboss.org> | 2009-09-29 19:10:15 (GMT) |
commit | 8b9020458a8576459040fce985ab140f0876e2f1 (patch) | |
tree | 63c9ba43ea7673f6662f222b54d8ba93cf480a2d /Lib/test/test_popen2.py | |
parent | 7e7a3ec901be55c868c800d541b5a1622e0ec7fb (diff) | |
download | cpython-8b9020458a8576459040fce985ab140f0876e2f1.zip cpython-8b9020458a8576459040fce985ab140f0876e2f1.tar.gz cpython-8b9020458a8576459040fce985ab140f0876e2f1.tar.bz2 |
#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/test_popen2.py')
-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 743b873..1383c62 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) |