]> git.ipfire.org Git - pakfire.git/commitdiff
tests: execute: Add test to catch exceptions in logger
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Jul 2022 10:40:38 +0000 (10:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Jul 2022 10:40:38 +0000 (10:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/python/execute.py

index 8c2cc27cb569f60e8e859092c0a4bee0e54a7f88..575216cca700456fe20377eb20264fa4dca76958 100755 (executable)
@@ -86,6 +86,19 @@ class Test(unittest.TestCase):
 
                self.pakfire.execute(["/command", "lines", "10", "20"], logging_callback=log)
 
+       def test_execute_logger_exceptions(self):
+               """
+                       The logger callback will raise an Exception which should be handled
+               """
+               def log(priority, message):
+                       raise RuntimeError(message)
+
+               with self.assertRaises(RuntimeError):
+                       self.pakfire.execute(
+                               ["/command", "echo", "Hello World!"],
+                               logging_callback=log,
+                       )
+
        # This is an interactive test which cannot be performed automatically
        #def test_shell(self):
        #       self.pakfire.execute(["/bin/bash", "-i"])