tests/misc.py

changeset 75
3ec747dfbfb9
parent 74
831d9f81a48c
child 78
1970afe52da4
equal deleted inserted replaced
74:831d9f81a48c 75:3ec747dfbfb9
157 yield report_problem( 157 yield report_problem(
158 'moved-to-with-extension', 158 'moved-to-with-extension',
159 bad_object = model.body[0], 159 bad_object = model.body[0],
160 ) 160 )
161 161
162 @problem_type('bfc-invertnext-not-on-subfile',
163 severity = 'hold',
164 message = '"BFC INVERTNEXT" not followed by a type-1 line',
165 )
166 def bfc_invertnext_not_on_subfile_test(model):
167 def get_invertnexts(model):
168 yield from [
169 (index, element)
170 for index, element in enumerate(model.body)
171 if isinstance(element, linetypes.MetaCommand) \
172 and element.text == 'BFC INVERTNEXT'
173 ]
174 def has_subfile_after_invertnext(index):
175 index_subfile = index + 1 # subfile reference should be on the next line
176 if index_subfile >= len(model.body):
177 return False # past the end...
178 else:
179 element = model.body[index_subfile]
180 return isinstance(element, linetypes.SubfileReference)
181 for index, invertnext in get_invertnexts(model):
182 if not has_subfile_after_invertnext(index):
183 yield report_problem('bfc-invertnext-not-on-subfile',
184 bad_object = model.body[index],
185 )
186
162 manifest = { 187 manifest = {
163 'tests': [ 188 'tests': [
164 colours_test, 189 colours_test,
165 syntax_errors, 190 syntax_errors,
166 bad_header, 191 bad_header,
169 unofficiality_test, 194 unofficiality_test,
170 header_bfc_test, 195 header_bfc_test,
171 keywords_tests, 196 keywords_tests,
172 colour_24_test, 197 colour_24_test,
173 moved_to_with_extension_test, 198 moved_to_with_extension_test,
199 bfc_invertnext_not_on_subfile_test,
174 ], 200 ],
175 } 201 }

mercurial