|
4 | 4 | more complex. See test_inputtransformer2_line for tests for line-based |
5 | 5 | transformations. |
6 | 6 | """ |
| 7 | +import platform |
7 | 8 | import string |
8 | 9 | import sys |
9 | 10 | from textwrap import dedent |
@@ -319,33 +320,48 @@ def test_check_complete(): |
319 | 320 | assert cc("def f():\n x=0\n \\\n ") == ("incomplete", 2) |
320 | 321 |
|
321 | 322 |
|
322 | | -def test_check_complete_II(): |
| 323 | +@pytest.mark.skipif(platform.python_implementation() == "PyPy", reason="fail on pypy") |
| 324 | +@pytest.mark.parametrize( |
| 325 | + "value, expected", |
| 326 | + [ |
| 327 | + ('''def foo():\n """''', ("incomplete", 4)), |
| 328 | + ("""async with example:\n pass""", ("incomplete", 4)), |
| 329 | + ("""async with example:\n pass\n """, ("complete", None)), |
| 330 | + ], |
| 331 | +) |
| 332 | +def test_check_complete_II(value, expected): |
323 | 333 | """ |
324 | 334 | Test that multiple line strings are properly handled. |
325 | 335 |
|
326 | 336 | Separate test function for convenience |
327 | 337 |
|
328 | 338 | """ |
329 | 339 | cc = ipt2.TransformerManager().check_complete |
330 | | - assert cc('''def foo():\n """''') == ("incomplete", 4) |
331 | | - |
332 | | - |
333 | | -def test_check_complete_invalidates_sunken_brackets(): |
| 340 | + assert cc(value) == expected |
| 341 | + |
| 342 | + |
| 343 | +@pytest.mark.parametrize( |
| 344 | + "value, expected", |
| 345 | + [ |
| 346 | + (")", ("invalid", None)), |
| 347 | + ("]", ("invalid", None)), |
| 348 | + ("}", ("invalid", None)), |
| 349 | + (")(", ("invalid", None)), |
| 350 | + ("][", ("invalid", None)), |
| 351 | + ("}{", ("invalid", None)), |
| 352 | + ("]()(", ("invalid", None)), |
| 353 | + ("())(", ("invalid", None)), |
| 354 | + (")[](", ("invalid", None)), |
| 355 | + ("()](", ("invalid", None)), |
| 356 | + ], |
| 357 | +) |
| 358 | +def test_check_complete_invalidates_sunken_brackets(value, expected): |
334 | 359 | """ |
335 | 360 | Test that a single line with more closing brackets than the opening ones is |
336 | 361 | interpreted as invalid |
337 | 362 | """ |
338 | 363 | cc = ipt2.TransformerManager().check_complete |
339 | | - assert cc(")") == ("invalid", None) |
340 | | - assert cc("]") == ("invalid", None) |
341 | | - assert cc("}") == ("invalid", None) |
342 | | - assert cc(")(") == ("invalid", None) |
343 | | - assert cc("][") == ("invalid", None) |
344 | | - assert cc("}{") == ("invalid", None) |
345 | | - assert cc("]()(") == ("invalid", None) |
346 | | - assert cc("())(") == ("invalid", None) |
347 | | - assert cc(")[](") == ("invalid", None) |
348 | | - assert cc("()](") == ("invalid", None) |
| 364 | + assert cc(value) == expected |
349 | 365 |
|
350 | 366 |
|
351 | 367 | def test_null_cleanup_transformer(): |
|
0 commit comments