[Python-checkins] python/dist/src/Lib/test test_subprocess.py, 1.16, 1.17

astrand at users.sourceforge.net astrand at users.sourceforge.net
Sat Jan 1 10:36:39 CET 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24099/d/test

Modified Files:
	test_subprocess.py 
Log Message:
New subprocess utility function: check_call. Closes #1071764.

Index: test_subprocess.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- test_subprocess.py	30 Nov 2004 21:04:45 -0000	1.16
+++ test_subprocess.py	1 Jan 2005 09:36:35 -0000	1.17
@@ -44,6 +44,22 @@
                               "import sys; sys.exit(47)"])
         self.assertEqual(rc, 47)
 
+    def test_check_call_zero(self):
+        # check_call() function with zero return code
+        rc = subprocess.check_call([sys.executable, "-c",
+                                    "import sys; sys.exit(0)"])
+        self.assertEqual(rc, 0)
+
+    def test_check_call_nonzero(self):
+        # check_call() function with non-zero return code
+        try:
+            subprocess.check_call([sys.executable, "-c",
+                                   "import sys; sys.exit(47)"])
+        except subprocess.CalledProcessError, e:
+            self.assertEqual(e.errno, 47)
+        else:
+            self.fail("Expected CalledProcessError")
+
     def test_call_kwargs(self):
         # call() function with keyword args
         newenv = os.environ.copy()



More information about the Python-checkins mailing list