Fix log output on empty message queue
authorReto Buerki <reet@codelabs.ch>
Tue, 26 Sep 2017 14:02:12 +0000 (16:02 +0200)
committerReto Buerki <reet@codelabs.ch>
Tue, 26 Sep 2017 14:02:59 +0000 (16:02 +0200)
Auditors: ken

src/output.py
test/test_output.py

index eea2bec..64124c1 100644 (file)
@@ -149,6 +149,7 @@ def produce_biosinfo():
 
 def produce_log():
     "Append warnings and errors during generation"
+    result = ""
     if message.messagequeue:
         result = produceLine("Log:", SPACES_MAIN)
         for msg in message.messagequeue:
index 4368144..8ed21e5 100644 (file)
@@ -264,7 +264,7 @@ class TestOutput:
         assert test_success()[1] is True
         assert test_fail()[1] is False
 
-    def test_produce_productinfo(self):
+    def test_produce_log(self):
 
         successline = ("""     Log:\n       * WARNING *: Warning1\n""")
 
@@ -273,11 +273,17 @@ class TestOutput:
 
         @mock.patch.object(message, "messagequeue", mock_queue)
         def test_success():
-            print output.produce_log()
             return output.produce_log()
 
         assert test_success() == (successline, True)
 
+        mock_queue = []
+
+        @mock.patch.object(message, "messagequeue", mock_queue)
+        def test_empty():
+            return output.produce_log()
+        assert test_empty() == ("", True)
+
     def test_runCommand(self):
 
         def command_fail(*args, **kwargs):