127 message = problem.problem_class.message |
127 message = problem.problem_class.message |
128 if callable(message): |
128 if callable(message): |
129 message = message(**problem.args) |
129 message = message(**problem.args) |
130 return message |
130 return message |
131 |
131 |
132 def format_report_html(report, model, test_suite): |
|
133 messages = [] |
|
134 for problem in report['problems']: |
|
135 ldraw_code = model.body[problem.body_index].textual_representation() |
|
136 message = str.format( |
|
137 '<li class="{problem_type}">{model_name}:{line_number}:' |
|
138 '{problem_type}: {message}<br />{ldraw_code}</li>', |
|
139 model_name = model.name, |
|
140 line_number = problem.line_number, |
|
141 problem_type = problem.severity, |
|
142 message = problem_text(problem, test_suite), |
|
143 ldraw_code = ldraw_code, |
|
144 ) |
|
145 messages.append(message) |
|
146 return '\n'.join(messages) |
|
147 |
|
148 def iterate_problems(test_suite): |
132 def iterate_problems(test_suite): |
149 for test_function in test_suite['tests']: |
133 for test_function in test_suite['tests']: |
150 yield from test_function.ldcheck_problem_types.values() |
134 yield from test_function.ldcheck_problem_types.values() |
151 |
135 |
152 def all_problem_types(test_suite): |
136 def all_problem_types(test_suite): |
153 return sorted( |
137 return sorted( |
154 iterate_problems(test_suite), |
138 iterate_problems(test_suite), |
155 key = lambda problem_type: problem_type.name |
139 key = lambda problem_type: problem_type.name |
156 ) |
140 ) |
157 |
|
158 |
141 |
159 if __name__ == '__main__': |
142 if __name__ == '__main__': |
160 from pprint import pprint |
143 from pprint import pprint |
161 pprint(load_tests()) |
144 pprint(load_tests()) |