mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-07 13:24:39 +08:00
Fix #139: newlines in async for comprehension
This commit is contained in:
@@ -51,6 +51,7 @@ Simon Ruggier (@sruggier)
|
|||||||
Élie Gouzien (@ElieGouzien)
|
Élie Gouzien (@ElieGouzien)
|
||||||
Tim Gates (@timgates42) <tim.gates@iress.com>
|
Tim Gates (@timgates42) <tim.gates@iress.com>
|
||||||
Batuhan Taskaya (@isidentical) <isidentical@gmail.com>
|
Batuhan Taskaya (@isidentical) <isidentical@gmail.com>
|
||||||
|
Jocelyn Boullier (@Kazy) <jocelyn@boullier.bzh>
|
||||||
|
|
||||||
|
|
||||||
Note: (@user) means a github user name.
|
Note: (@user) means a github user name.
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ def works_ge_py35(each_version):
|
|||||||
version_info = parse_version_string(each_version)
|
version_info = parse_version_string(each_version)
|
||||||
return Checker(each_version, version_info >= (3, 5))
|
return Checker(each_version, version_info >= (3, 5))
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def works_ge_py36(each_version):
|
||||||
|
version_info = parse_version_string(each_version)
|
||||||
|
return Checker(each_version, version_info >= (3, 6))
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def works_ge_py38(each_version):
|
def works_ge_py38(each_version):
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ def _create_token_collection(version_info):
|
|||||||
'finally', 'while', 'with', 'return', 'continue',
|
'finally', 'while', 'with', 'return', 'continue',
|
||||||
'break', 'del', 'pass', 'global', 'assert')
|
'break', 'del', 'pass', 'global', 'assert')
|
||||||
if version_info >= (3, 5):
|
if version_info >= (3, 5):
|
||||||
ALWAYS_BREAK_TOKENS += ('async', 'nonlocal')
|
ALWAYS_BREAK_TOKENS += ('nonlocal', )
|
||||||
pseudo_token_compiled = _compile(PseudoToken)
|
pseudo_token_compiled = _compile(PseudoToken)
|
||||||
return TokenCollection(
|
return TokenCollection(
|
||||||
pseudo_token_compiled, single_quoted, triple_quoted, endpats,
|
pseudo_token_compiled, single_quoted, triple_quoted, endpats,
|
||||||
|
|||||||
@@ -87,6 +87,39 @@ def test_async_for(works_ge_py35):
|
|||||||
works_ge_py35.parse("async def foo():\n async for a in b: pass")
|
works_ge_py35.parse("async def foo():\n async for a in b: pass")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("body", [
|
||||||
|
"""[1 async for a in b
|
||||||
|
]""",
|
||||||
|
"""[1 async
|
||||||
|
for a in b
|
||||||
|
]""",
|
||||||
|
"""[
|
||||||
|
1
|
||||||
|
async for a in b
|
||||||
|
]""",
|
||||||
|
"""[
|
||||||
|
1
|
||||||
|
async for a
|
||||||
|
in b
|
||||||
|
]""",
|
||||||
|
"""[
|
||||||
|
1
|
||||||
|
async
|
||||||
|
for
|
||||||
|
a
|
||||||
|
in
|
||||||
|
b
|
||||||
|
]""",
|
||||||
|
""" [
|
||||||
|
1 async for a in b
|
||||||
|
]""",
|
||||||
|
])
|
||||||
|
def test_async_for_comprehension_newline(works_ge_py36, body):
|
||||||
|
# Issue #139
|
||||||
|
works_ge_py36.parse("""async def foo():
|
||||||
|
{}""".format(body))
|
||||||
|
|
||||||
|
|
||||||
def test_async_with(works_ge_py35):
|
def test_async_with(works_ge_py35):
|
||||||
works_ge_py35.parse("async def foo():\n async with a: pass")
|
works_ge_py35.parse("async def foo():\n async with a: pass")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user