From eb3be13c81aefbb341f17a0fd419df41dda36873 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 14 Jan 2021 13:36:09 +0000 Subject: [PATCH] tests: python: Check return codes of pakfire_execute() Signed-off-by: Michael Tremer --- tests/python/execute.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.47.2