]> git.ipfire.org Git - pakfire.git/commitdiff
tests: python: Check return codes of pakfire_execute()
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 14 Jan 2021 13:36:09 +0000 (13:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 14 Jan 2021 13:36:09 +0000 (13:36 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/python/execute.py

index b9d0e254a8fc8e94b8108903b1c9c63782deb7dd..eb25534bd1c8ab2380e46c16e29ff1c694b5bf70 100755 (executable)
@@ -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