Refactor the assertion in colorize_result() to improve test coverage
authorAlexander Popov <alex.popov@linux.com>
Mon, 18 Sep 2023 05:58:44 +0000 (08:58 +0300)
committerAlexander Popov <alex.popov@linux.com>
Mon, 18 Sep 2023 05:58:44 +0000 (08:58 +0300)
kernel_hardening_checker/engine.py

index 4fdc222e7e8ac3d9fec6a2cf0a3c60c411f8c918..64be2043b3f679c1d577dd92e4334ecbd1d794af 100644 (file)
@@ -20,10 +20,9 @@ def colorize_result(input_text):
         return input_text
     if input_text.startswith('OK'):
         color = GREEN_COLOR
-    elif input_text.startswith('FAIL:'):
-        color = RED_COLOR
     else:
-        assert(False), f'unexpected result "{input_text}"'
+        assert(input_text.startswith('FAIL:')), f'unexpected result "{input_text}"'
+        color = RED_COLOR
     return f'{color}{input_text}{COLOR_END}'