Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_popen2.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | b36cb4602e21 |
| children |
| rev | line source |
|---|---|
|
10376
337733ce9593
Test for popen2 module, by Chris Tismer.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
2 """Test script for popen2.py""" |
|
10376
337733ce9593
Test for popen2 module, by Chris Tismer.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 |
|
41690
6c4aa4611c88
Deprecate os.popen* and popen2 module in favor of the subprocess module.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41532
diff
changeset
|
4 import warnings |
|
6c4aa4611c88
Deprecate os.popen* and popen2 module in favor of the subprocess module.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41532
diff
changeset
|
5 warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*", |
|
6c4aa4611c88
Deprecate os.popen* and popen2 module in favor of the subprocess module.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41532
diff
changeset
|
6 DeprecationWarning) |
|
6c4aa4611c88
Deprecate os.popen* and popen2 module in favor of the subprocess module.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41532
diff
changeset
|
7 warnings.filterwarnings("ignore", "os\.popen. is deprecated.*", |
|
6c4aa4611c88
Deprecate os.popen* and popen2 module in favor of the subprocess module.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41532
diff
changeset
|
8 DeprecationWarning) |
|
6c4aa4611c88
Deprecate os.popen* and popen2 module in favor of the subprocess module.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41532
diff
changeset
|
9 |
|
14236
58d7995ce795
Added os.popen2() and os.popen3() for non-Windows platforms.
Fred Drake <fdrake@acm.org>
parents:
13727
diff
changeset
|
10 import os |
|
16363
c29ca1980303
Checking in patch #103478 -- makes popen2 and fork1 tested on BeOS.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
14361
diff
changeset
|
11 import sys |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
12 import unittest |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
13 import popen2 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
14 |
|
52355
228cfb6e2900
fix incorrect auto-translation of TestSkipped -> unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents:
52353
diff
changeset
|
15 from test.test_support import run_unittest, reap_children |
|
14236
58d7995ce795
Added os.popen2() and os.popen3() for non-Windows platforms.
Fred Drake <fdrake@acm.org>
parents:
13727
diff
changeset
|
16 |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
17 if sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos': |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
18 # Locks get messed up or something. Generally we're supposed |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
19 # to avoid mixing "posix" fork & exec with native threads, and |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
20 # they may be right about that after all. |
|
52355
228cfb6e2900
fix incorrect auto-translation of TestSkipped -> unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents:
52353
diff
changeset
|
21 raise unittest.SkipTest("popen2() doesn't work on " + sys.platform) |
|
10376
337733ce9593
Test for popen2 module, by Chris Tismer.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
23 # if we don't have os.popen, check that |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
24 # we have os.fork. if not, skip the test |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
25 # (by raising an ImportError) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
26 try: |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
27 from os import popen |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
28 del popen |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
29 except ImportError: |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
30 from os import fork |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
31 del fork |
|
10376
337733ce9593
Test for popen2 module, by Chris Tismer.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
33 class Popen2Test(unittest.TestCase): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
34 cmd = "cat" |
|
14236
58d7995ce795
Added os.popen2() and os.popen3() for non-Windows platforms.
Fred Drake <fdrake@acm.org>
parents:
13727
diff
changeset
|
35 if os.name == "nt": |
|
58d7995ce795
Added os.popen2() and os.popen3() for non-Windows platforms.
Fred Drake <fdrake@acm.org>
parents:
13727
diff
changeset
|
36 cmd = "more" |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
37 teststr = "ab cd\n" |
|
14361
5c51c096de3b
The "more" cmd varies across Windows flavors, sometimes adding stray
Tim Peters <tim.peters@gmail.com>
parents:
14236
diff
changeset
|
38 # "more" doesn't act the same way across Windows flavors, |
|
5c51c096de3b
The "more" cmd varies across Windows flavors, sometimes adding stray
Tim Peters <tim.peters@gmail.com>
parents:
14236
diff
changeset
|
39 # sometimes adding an extra newline at the start or the |
|
5c51c096de3b
The "more" cmd varies across Windows flavors, sometimes adding stray
Tim Peters <tim.peters@gmail.com>
parents:
14236
diff
changeset
|
40 # end. So we strip whitespace off both ends for comparison. |
|
5c51c096de3b
The "more" cmd varies across Windows flavors, sometimes adding stray
Tim Peters <tim.peters@gmail.com>
parents:
14236
diff
changeset
|
41 expected = teststr.strip() |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
42 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
43 def setUp(self): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
44 popen2._cleanup() |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
45 # When the test runs, there shouldn't be any open pipes |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
46 self.assertFalse(popen2._active, "Active pipes when test starts" + |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
47 repr([c.cmd for c in popen2._active])) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
48 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
49 def tearDown(self): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
50 for inst in popen2._active: |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
51 inst.wait() |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
52 popen2._cleanup() |
|
59329
84130c2265dc
Fix transient refleak in test_popen2.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
56294
diff
changeset
|
53 self.assertFalse(popen2._active, "popen2._active not empty") |
|
84130c2265dc
Fix transient refleak in test_popen2.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
56294
diff
changeset
|
54 # The os.popen*() API delegates to the subprocess module (on Unix) |
|
84130c2265dc
Fix transient refleak in test_popen2.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
56294
diff
changeset
|
55 import subprocess |
|
84130c2265dc
Fix transient refleak in test_popen2.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
56294
diff
changeset
|
56 for inst in subprocess._active: |
|
84130c2265dc
Fix transient refleak in test_popen2.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
56294
diff
changeset
|
57 inst.wait() |
|
84130c2265dc
Fix transient refleak in test_popen2.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
56294
diff
changeset
|
58 subprocess._cleanup() |
|
84130c2265dc
Fix transient refleak in test_popen2.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
56294
diff
changeset
|
59 self.assertFalse(subprocess._active, "subprocess._active not empty") |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41216
diff
changeset
|
60 reap_children() |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
61 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
62 def validate_output(self, teststr, expected_out, r, w, e=None): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
63 w.write(teststr) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
64 w.close() |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
65 got = r.read() |
|
66348
614c84670c63
Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
59329
diff
changeset
|
66 self.assertEqual(expected_out, got.strip(), "wrote %r read %r" % |
|
614c84670c63
Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
59329
diff
changeset
|
67 (teststr, got)) |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
68 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
69 if e is not None: |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
70 got = e.read() |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
71 self.assertFalse(got, "unexpected %r on stderr" % got) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41216
diff
changeset
|
72 |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
73 def test_popen2(self): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
74 r, w = popen2.popen2(self.cmd) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
75 self.validate_output(self.teststr, self.expected, r, w) |
|
14236
58d7995ce795
Added os.popen2() and os.popen3() for non-Windows platforms.
Fred Drake <fdrake@acm.org>
parents:
13727
diff
changeset
|
76 |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
77 def test_popen3(self): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
78 if os.name == 'posix': |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
79 r, w, e = popen2.popen3([self.cmd]) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
80 self.validate_output(self.teststr, self.expected, r, w, e) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
81 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
82 r, w, e = popen2.popen3(self.cmd) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
83 self.validate_output(self.teststr, self.expected, r, w, e) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
84 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
85 def test_os_popen2(self): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
86 # same test as test_popen2(), but using the os.popen*() API |
|
56295
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
87 if os.name == 'posix': |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
88 w, r = os.popen2([self.cmd]) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
89 self.validate_output(self.teststr, self.expected, r, w) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
90 |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
91 w, r = os.popen2(["echo", self.teststr]) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
92 got = r.read() |
|
66348
614c84670c63
Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
59329
diff
changeset
|
93 self.assertEqual(got, self.teststr + "\n") |
|
56295
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
94 |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
95 w, r = os.popen2(self.cmd) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
96 self.validate_output(self.teststr, self.expected, r, w) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
97 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
98 def test_os_popen3(self): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
99 # same test as test_popen3(), but using the os.popen*() API |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
100 if os.name == 'posix': |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
101 w, r, e = os.popen3([self.cmd]) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
102 self.validate_output(self.teststr, self.expected, r, w, e) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
103 |
|
56295
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
104 w, r, e = os.popen3(["echo", self.teststr]) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
105 got = r.read() |
|
66348
614c84670c63
Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
59329
diff
changeset
|
106 self.assertEqual(got, self.teststr + "\n") |
|
56295
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
107 got = e.read() |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
108 self.assertFalse(got, "unexpected %r on stderr" % got) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
109 |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
110 w, r, e = os.popen3(self.cmd) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
111 self.validate_output(self.teststr, self.expected, r, w, e) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
112 |
|
56295
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
113 def test_os_popen4(self): |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
114 if os.name == 'posix': |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
115 w, r = os.popen4([self.cmd]) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
116 self.validate_output(self.teststr, self.expected, r, w) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
117 |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
118 w, r = os.popen4(["echo", self.teststr]) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
119 got = r.read() |
|
66348
614c84670c63
Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
59329
diff
changeset
|
120 self.assertEqual(got, self.teststr + "\n") |
|
56295
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
121 |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
122 w, r = os.popen4(self.cmd) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
123 self.validate_output(self.teststr, self.expected, r, w) |
|
7e1856167c4a
Merged revisions 75143 via svnmerge from
Philip Jenvey <pjenvey@underboss.org>
parents:
41690
diff
changeset
|
124 |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41216
diff
changeset
|
125 |
|
41216
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
126 def test_main(): |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
127 run_unittest(Popen2Test) |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
128 |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
129 if __name__ == "__main__": |
|
8bb570ae4c45
Patch #1676994: Refactor test_popen2 to use unittest.
Collin Winter <collinw@gmail.com>
parents:
38961
diff
changeset
|
130 test_main() |
