From d24e232af55bb95db0a63db470e8d4fa8d369d54 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 21 Jul 2022 10:23:15 +0000 Subject: [PATCH] tests: execute: Check if logger returned the correct output Signed-off-by: Michael Tremer --- tests/python/execute.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/python/execute.py b/tests/python/execute.py index 900d87aae..8c2cc27cb 100755 --- a/tests/python/execute.py +++ b/tests/python/execute.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 +import logging import os import pakfire import unittest @@ -77,9 +78,13 @@ class Test(unittest.TestCase): def test_execute_logger(self): def log(priority, message): - print("LOG (%s): %s" % (priority, message.rstrip())) + # Priority must be INFO + self.assertEqual(priority, logging.INFO) - self.pakfire.execute(["/command", "lines", "10"], logging_callback=log) + # All lines must be 20 characters long + self.assertEqual(len(message), 20) + + self.pakfire.execute(["/command", "lines", "10", "20"], logging_callback=log) # This is an interactive test which cannot be performed automatically #def test_shell(self): -- 2.47.3