summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py34
1 files changed, 30 insertions, 4 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 3f877f2..c9a3e1b 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -702,10 +702,36 @@ class ProcessTestCase(unittest.TestCase):
p.terminate()
self.assertNotEqual(p.wait(), 0)
+class CommandTests(unittest.TestCase):
+# The module says:
+# "NB This only works (and is only relevant) for UNIX."
+#
+# Actually, getoutput should work on any platform with an os.popen, but
+# I'll take the comment as given, and skip this suite.
+ if os.name == 'posix':
+
+ def test_getoutput(self):
+ self.assertEquals(subprocess.getoutput('echo xyzzy'), 'xyzzy')
+ self.assertEquals(subprocess.getstatusoutput('echo xyzzy'),
+ (0, 'xyzzy'))
+
+ # we use mkdtemp in the next line to create an empty directory
+ # under our exclusive control; from that, we can invent a pathname
+ # that we _know_ won't exist. This is guaranteed to fail.
+ dir = None
+ try:
+ dir = tempfile.mkdtemp()
+ name = os.path.join(dir, "foo")
+
+ status, output = subprocess.getstatusoutput('cat ' + name)
+ self.assertNotEquals(status, 0)
+ finally:
+ if dir is not None:
+ os.rmdir(dir)
+
def test_main():
- support.run_unittest(ProcessTestCase)
- if hasattr(support, "reap_children"):
- support.reap_children()
+ support.run_unittest(ProcessTestCase, CommandTests)
+ support.reap_children()
if __name__ == "__main__":
- unittest.main() # XXX test_main()
+ test_main()