Skip to content

Commit 8d5d657

Browse files
committed
Handle subprocess error.
1 parent 254a9fb commit 8d5d657

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010

1111
def assert_command_output(command, expected_output):
12-
output = subprocess.check_output(command, shell=True).decode("utf-8").strip()
13-
# normalize line endings for cross-platform compatibility
12+
try:
13+
output = subprocess.check_output(command, shell=True).decode("utf-8").strip()
14+
except subprocess.CalledProcessError as error:
15+
output = error.output.decode("utf-8").strip()
1416
output = output.replace("\r\n", "\n").strip()
1517
assert output == expected_output.replace("\r\n", "\n").strip()
1618
return output

0 commit comments

Comments
 (0)