|
26 | 26 |
|
27 | 27 | from cylc.flow.scripts.lint import (
|
28 | 28 | MANUAL_DEPRECATIONS,
|
| 29 | + check_lowercase_family_names, |
29 | 30 | get_cylc_files,
|
30 | 31 | get_pyproject_toml,
|
31 | 32 | get_reference_rst,
|
@@ -240,77 +241,81 @@ def test_check_cylc_file_line_no():
|
240 | 241 |
|
241 | 242 |
|
242 | 243 | @pytest.mark.parametrize(
|
243 |
| - 'inherit_line', |
244 |
| - ( |
245 |
| - param(item, id=str(ind)) |
246 |
| - for ind, item in enumerate([ |
247 |
| - # lowercase family names are not permitted |
248 |
| - 'inherit = g', |
249 |
| - 'inherit = foo, b, a, r', |
250 |
| - 'inherit = FOO, bar', |
251 |
| - 'inherit = None, bar', |
252 |
| - 'inherit = A, b, C', |
253 |
| - 'inherit = "A", "b"', |
254 |
| - "inherit = 'A', 'b'", |
255 |
| - # parameters, jinja2 and empy should be ignored |
256 |
| - # but any lowercase chars before or after should not |
257 |
| - 'inherit = a<x>z', |
258 |
| - 'inherit = a{{ x }}z', |
259 |
| - 'inherit = a@( x )z', |
260 |
| - ]) |
261 |
| - ) |
| 244 | + 'line', |
| 245 | + [ |
| 246 | + # lowercase family names are not permitted |
| 247 | + 'inherit = g', |
| 248 | + 'inherit = FOO, bar', |
| 249 | + 'inherit = None, bar', |
| 250 | + 'inherit = A, b, C', |
| 251 | + 'inherit = "A", "b"', |
| 252 | + "inherit = 'A', 'b'", |
| 253 | + 'inherit = FOO_BAr', |
| 254 | + # whitespace & trailing commas |
| 255 | + ' inherit = a , ', |
| 256 | + # parameters, jinja2 and empy should be ignored |
| 257 | + # but any lowercase chars before or after should not |
| 258 | + 'inherit = A<x>z', |
| 259 | + 'inherit = A{{ x }}z', |
| 260 | + 'inherit = N{# #}one', |
| 261 | + 'inherit = A@( x )z', |
| 262 | + ] |
262 | 263 | )
|
263 |
| -def test_inherit_lowercase_matches(inherit_line): |
264 |
| - lint = lint_text(inherit_line, ['style']) |
265 |
| - assert any('S007' in msg for msg in lint.messages) |
| 264 | +def test_check_lowercase_family_names__true(line): |
| 265 | + assert check_lowercase_family_names(line) is True |
266 | 266 |
|
267 | 267 |
|
268 | 268 | @pytest.mark.parametrize(
|
269 |
| - 'inherit_line', |
270 |
| - ( |
271 |
| - param(item, id=str(ind)) |
272 |
| - for ind, item in enumerate([ |
273 |
| - # undefined values are ok |
274 |
| - 'inherit =', |
275 |
| - 'inherit = ', |
276 |
| - # none, None and root are ok |
277 |
| - 'inherit = none', |
278 |
| - 'inherit = None', |
279 |
| - 'inherit = root', |
280 |
| - # trailing commas and whitespace are ok |
281 |
| - 'inherit = None,', |
282 |
| - 'inherit = None, ', |
283 |
| - 'inherit = None , ', |
284 |
| - # uppercase family names are ok |
285 |
| - 'inherit = None, FOO, BAR', |
286 |
| - 'inherit = FOO', |
287 |
| - 'inherit = BAZ', |
288 |
| - 'inherit = root', |
289 |
| - 'inherit = FOO_BAR_0', |
290 |
| - # parameters should be ignored |
291 |
| - 'inherit = A<a>Z', |
292 |
| - 'inherit = <a=1, b-1, c+1>', |
293 |
| - # jinja2 should be ignored |
| 269 | + 'line', |
| 270 | + [ |
| 271 | + # undefined values are ok |
| 272 | + 'inherit =', |
| 273 | + 'inherit = ', |
| 274 | + # none, None and root are ok |
| 275 | + 'inherit = none', |
| 276 | + 'inherit = None', |
| 277 | + 'inherit = root', |
| 278 | + # whitespace & trailing commas |
| 279 | + 'inherit = None,', |
| 280 | + 'inherit = None, ', |
| 281 | + ' inherit = None , ', |
| 282 | + # uppercase family names are ok |
| 283 | + 'inherit = None, FOO, BAR', |
| 284 | + 'inherit = FOO', |
| 285 | + 'inherit = FOO_BAR_0', |
| 286 | + # parameters should be ignored |
| 287 | + 'inherit = A<a>Z', |
| 288 | + 'inherit = <a=1, b-1, c+1>', |
| 289 | + # jinja2 should be ignored |
| 290 | + param( |
294 | 291 | 'inherit = A{{ a }}Z, {% for x in range(5) %}'
|
295 | 292 | 'A{{ x }}, {% endfor %}',
|
296 |
| - # empy should be ignored |
297 |
| - 'inherit = A@( a )Z', |
298 |
| - # trailing comments should be ignored |
299 |
| - 'inherit = A, B # no, comment', |
300 |
| - 'inherit = # a', |
301 |
| - # quotes are ok |
302 |
| - 'inherit = "A", "B"', |
303 |
| - "inherit = 'A', 'B'", |
304 |
| - 'inherit = "None", B', |
305 |
| - 'inherit = <a = 1, b - 1>', |
306 |
| - # one really awkward, but valid example |
| 293 | + id='jinja2-long' |
| 294 | + ), |
| 295 | + # empy should be ignored |
| 296 | + 'inherit = A@( a )Z', |
| 297 | + # trailing comments should be ignored |
| 298 | + 'inherit = A, B # no, comment', |
| 299 | + 'inherit = # a', |
| 300 | + # quotes are ok |
| 301 | + 'inherit = "A", "B"', |
| 302 | + "inherit = 'A', 'B'", |
| 303 | + 'inherit = "None", B', |
| 304 | + 'inherit = <a = 1, b - 1>', |
| 305 | + # one really awkward, but valid example |
| 306 | + param( |
307 | 307 | 'inherit = none, FOO_BAR_0, "<a - 1>", A<a>Z, A{{a}}Z, A@(a)Z',
|
308 |
| - ]) |
309 |
| - ) |
| 308 | + id='awkward' |
| 309 | + ), |
| 310 | + ] |
310 | 311 | )
|
311 |
| -def test_inherit_lowercase_not_match_none(inherit_line): |
312 |
| - lint = lint_text(inherit_line, ['style']) |
313 |
| - assert not any('S007' in msg for msg in lint.messages) |
| 312 | +def test_check_lowercase_family_names__false(line): |
| 313 | + assert check_lowercase_family_names(line) is False |
| 314 | + |
| 315 | + |
| 316 | +def test_inherit_lowercase_matches(): |
| 317 | + lint = lint_text('inherit = a', ['style']) |
| 318 | + assert any('S007' in msg for msg in lint.messages) |
314 | 319 |
|
315 | 320 |
|
316 | 321 | @pytest.mark.parametrize(
|
|
0 commit comments