tests/misc.py

changeset 87
90105119ff90
parent 86
b25fc6f7eb70
child 88
6a0b43a5dec0
equal deleted inserted replaced
86:b25fc6f7eb70 87:90105119ff90
227 yield report_problem('unknown-metacommand', 227 yield report_problem('unknown-metacommand',
228 bad_object = element, 228 bad_object = element,
229 command_text = element.text, 229 command_text = element.text,
230 ) 230 )
231 231
232 @problem_type('bad-whitespace',
233 severity = 'hold',
234 message = lambda whitespaces: str.format(
235 'non-standard whitespace in description: {whitespaces}',
236 whitespaces = whitespaces,
237 )
238 )
239 def bad_whitespace_test(model):
240 if model.header.valid:
241 import re
242 description = model.header.description
243 # checking against string.whitespace is not adequate enough
244 # because it only contains ASCII characters. So checking using a
245 # regular expression is necessary.
246 bad_whitespaces = set(re.findall('\s', description)) - {' '}
247 if bad_whitespaces:
248 yield report_problem(
249 'bad-whitespace',
250 bad_object = model.body[0],
251 whitespaces = ', '.join(
252 repr(whitespace)
253 for whitespace in sorted(bad_whitespaces)
254 ),
255 )
256
232 manifest = { 257 manifest = {
233 'tests': [ 258 'tests': [
234 colours_test, 259 colours_test,
235 syntax_errors, 260 syntax_errors,
236 bad_header, 261 bad_header,
241 keywords_tests, 266 keywords_tests,
242 colour_24_test, 267 colour_24_test,
243 moved_to_with_extension_test, 268 moved_to_with_extension_test,
244 bfc_invertnext_not_on_subfile_test, 269 bfc_invertnext_not_on_subfile_test,
245 metacommands_test, 270 metacommands_test,
271 bad_whitespace_test,
246 ], 272 ],
247 } 273 }

mercurial