summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-06-03 06:14:06 (GMT)
committerGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-06-03 06:14:06 (GMT)
commitd6da7604d3eb19635f27e3d2d66e5a973cc26266 (patch)
treebcb7ec20810521ed6763b4fa1ad6f304d1bcde94 /Lib/test/test_subprocess.py
parent287e687648c5a443a11393d8311c83ed01e586e4 (diff)
downloadcpython-d6da7604d3eb19635f27e3d2d66e5a973cc26266.zip
cpython-d6da7604d3eb19635f27e3d2d66e5a973cc26266.tar.gz
cpython-d6da7604d3eb19635f27e3d2d66e5a973cc26266.tar.bz2
Issue #27167: Clarify the subprocess.CalledProcessError error message text
when the child process died due to a signal.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index a8f0a64..8a2352b 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1427,6 +1427,25 @@ class POSIXProcessTestCase(BaseTestCase):
p.wait()
self.assertEqual(-p.returncode, signal.SIGABRT)
+ def test_CalledProcessError_str_signal(self):
+ err = subprocess.CalledProcessError(-int(signal.SIGABRT), "fake cmd")
+ error_string = str(err)
+ # We're relying on the repr() of the signal.Signals intenum to provide
+ # the word signal, the signal name and the numeric value.
+ self.assertIn("signal", error_string.lower())
+ self.assertIn("SIGABRT", error_string)
+ self.assertIn(str(signal.SIGABRT), error_string)
+
+ def test_CalledProcessError_str_unknown_signal(self):
+ err = subprocess.CalledProcessError(-9876543, "fake cmd")
+ error_string = str(err)
+ self.assertIn("unknown signal 9876543.", error_string)
+
+ def test_CalledProcessError_str_non_zero(self):
+ err = subprocess.CalledProcessError(2, "fake cmd")
+ error_string = str(err)
+ self.assertIn("non-zero exit status 2.", error_string)
+
def test_preexec(self):
# DISCLAIMER: Setting environment variables is *not* a good use
# of a preexec_fn. This is merely a test.