Skip to content

Commit 12aff1a

Browse files
author
Benjy Wiener
committed
Add tests for subprocess.CalledProcessError.__str__
1 parent 7c2bb04 commit 12aff1a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Lib/test/test_subprocess.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,6 +2449,16 @@ def test_CalledProcessError_str_non_zero(self):
24492449
error_string = str(err)
24502450
self.assertIn("non-zero exit status 2.", error_string)
24512451

2452+
def test_CalledProcessError_str_quote_in_cmd(self):
2453+
err = subprocess.CalledProcessError(2, "fake ' cmd")
2454+
error_string = str(err)
2455+
self.assertStartsWith(error_string, 'Command "fake \' cmd" ')
2456+
2457+
def test_CalledProcessError_str_list_cmd(self):
2458+
err = subprocess.CalledProcessError(2, ["fake", "cmd"])
2459+
error_string = str(err)
2460+
self.assertStartsWith(error_string, "Command ['fake', 'cmd'] ")
2461+
24522462
def test_preexec(self):
24532463
# DISCLAIMER: Setting environment variables is *not* a good use
24542464
# of a preexec_fn. This is merely a test.

0 commit comments

Comments
 (0)