--- a/testsuite.py Mon Jan 22 17:05:10 2018 +0200 +++ b/testsuite.py Mon Jan 22 17:42:57 2018 +0200 @@ -85,16 +85,29 @@ return report def format_report(report, model, test_suite): + import colorama + colorama.init() result = [] for problem in report: problem_text = test_suite['messages'][problem['name']] if callable(problem_text): problem_text = problem_text(**problem['args']) + if problem['type'] == 'error': + text_colour = colorama.Fore.LIGHTRED_EX + elif problem['type'] == 'warning': + text_colour = colorama.Fore.LIGHTYELLOW_EX + else: + text_colour = '' message = str.format( - 'Line {}: {}\n\t{}', - problem['line-number'], - problem_text, - model.body[problem['body-index']].original_code + '{text_colour}{model_name}:{line_number}: {problem_type}: {message}' + '{colour_reset}\n\t{trouble_source}', + text_colour = text_colour, + model_name = model.name, + line_number = problem['line-number'], + problem_type = problem['type'], + message = problem_text, + colour_reset = colorama.Fore.RESET, + trouble_source = model.body[problem['body-index']].original_code, ) result.append((problem['line-number'], message)) return '\n'.join(