From: Michael Tremer Date: Thu, 14 Jan 2021 13:36:09 +0000 (+0000) Subject: tests: python: Check return codes of pakfire_execute() X-Git-Tag: 0.9.28~1285^2~856 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eb3be13c81aefbb341f17a0fd419df41dda36873;p=pakfire.git tests: python: Check return codes of pakfire_execute() Signed-off-by: Michael Tremer --- diff --git a/tests/python/execute.py b/tests/python/execute.py index b9d0e254a..eb25534bd 100755 --- a/tests/python/execute.py +++ b/tests/python/execute.py @@ -42,6 +42,15 @@ class Test(unittest.TestCase): with self.assertRaises(TypeError): self.pakfire.execute(["/usr/bin/sleep", "--help"], environ="VAR1=VAL1") + def test_return_value(self): + with self.assertRaises(pakfire.CommandExecutionError) as e: + self.pakfire.execute(["/bin/sh", "-c", "exit 123"]) + + # Extract return code + code, = e.exception.args + + self.assertTrue(code == 123) + def test_execute_non_existant_command(self): """ Executing non-existant commands should raise an error