From: Michael Tremer Date: Thu, 21 Jul 2022 10:40:38 +0000 (+0000) Subject: tests: execute: Add test to catch exceptions in logger X-Git-Tag: 0.9.28~653 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=849f29188fc66eee6533332e20004d571e8fd9c9;p=pakfire.git tests: execute: Add test to catch exceptions in logger Signed-off-by: Michael Tremer --- diff --git a/tests/python/execute.py b/tests/python/execute.py index 8c2cc27cb..575216cca 100755 --- a/tests/python/execute.py +++ b/tests/python/execute.py @@ -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"])