summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorPeter Astrand <astrand@lysator.liu.se>2005-01-01 09:36:35 (GMT)
committerPeter Astrand <astrand@lysator.liu.se>2005-01-01 09:36:35 (GMT)
commit454f76711c14f0a55119601bfe56a1ab5d2c0e04 (patch)
treef81416ce45244479ab525018c0b2078f8d591946 /Lib/test/test_subprocess.py
parented2dbe3f3344038dee8389f0ade335da1b3b559a (diff)
downloadcpython-454f76711c14f0a55119601bfe56a1ab5d2c0e04.zip
cpython-454f76711c14f0a55119601bfe56a1ab5d2c0e04.tar.gz
cpython-454f76711c14f0a55119601bfe56a1ab5d2c0e04.tar.bz2
New subprocess utility function: check_call. Closes #1071764.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index b26d40c..52f4d47 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -44,6 +44,22 @@ class ProcessTestCase(unittest.TestCase):
"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()