|
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 |
@@ -291,6 +292,7 @@ def test_check_complete_param(code, expected, number): |
291 | 292 | assert cc(code) == (expected, number) |
292 | 293 |
|
293 | 294 |
|
| 295 | +@pytest.mark.xfail(platform.python_implementation() == "PyPy", reason="fail on pypy") |
294 | 296 | @pytest.mark.xfail( |
295 | 297 | reason="Bug in python 3.9.8 – bpo 45738", |
296 | 298 | condition=sys.version_info in [(3, 9, 8, "final", 0), (3, 11, 0, "alpha", 2)], |
@@ -319,33 +321,48 @@ def test_check_complete(): |
319 | 321 | assert cc("def f():\n x=0\n \\\n ") == ("incomplete", 2) |
320 | 322 |
|
321 | 323 |
|
322 | | -def test_check_complete_II(): |
| 324 | +@pytest.mark.xfail(platform.python_implementation() == "PyPy", reason="fail on pypy") |
| 325 | +@pytest.mark.parametrize( |
| 326 | + "value, expected", |
| 327 | + [ |
| 328 | + ('''def foo():\n """''', ("incomplete", 4)), |
| 329 | + ("""async with example:\n pass""", ("incomplete", 4)), |
| 330 | + ("""async with example:\n pass\n """, ("complete", None)), |
| 331 | + ], |
| 332 | +) |
| 333 | +def test_check_complete_II(value, expected): |
323 | 334 | """ |
324 | 335 | Test that multiple line strings are properly handled. |
325 | 336 |
|
326 | 337 | Separate test function for convenience |
327 | 338 |
|
328 | 339 | """ |
329 | 340 | cc = ipt2.TransformerManager().check_complete |
330 | | - assert cc('''def foo():\n """''') == ("incomplete", 4) |
331 | | - |
332 | | - |
333 | | -def test_check_complete_invalidates_sunken_brackets(): |
| 341 | + assert cc(value) == expected |
| 342 | + |
| 343 | + |
| 344 | +@pytest.mark.parametrize( |
| 345 | + "value, expected", |
| 346 | + [ |
| 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 | + ("()](", ("invalid", None)), |
| 357 | + ], |
| 358 | +) |
| 359 | +def test_check_complete_invalidates_sunken_brackets(value, expected): |
334 | 360 | """ |
335 | 361 | Test that a single line with more closing brackets than the opening ones is |
336 | 362 | interpreted as invalid |
337 | 363 | """ |
338 | 364 | 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) |
| 365 | + assert cc(value) == expected |
349 | 366 |
|
350 | 367 |
|
351 | 368 | def test_null_cleanup_transformer(): |
|
0 commit comments