tests/misc.py

changeset 88
6a0b43a5dec0
parent 87
90105119ff90
child 94
109fb7cf658f
equal deleted inserted replaced
87:90105119ff90 88:6a0b43a5dec0
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
257 manifest = { 232 manifest = {
258 'tests': [ 233 'tests': [
259 colours_test, 234 colours_test,
260 syntax_errors, 235 syntax_errors,
261 bad_header, 236 bad_header,
266 keywords_tests, 241 keywords_tests,
267 colour_24_test, 242 colour_24_test,
268 moved_to_with_extension_test, 243 moved_to_with_extension_test,
269 bfc_invertnext_not_on_subfile_test, 244 bfc_invertnext_not_on_subfile_test,
270 metacommands_test, 245 metacommands_test,
271 bad_whitespace_test,
272 ], 246 ],
273 } 247 }

mercurial