mirror of
https://github.com/davidhalter/parso.git
synced 2026-10-26 14:27:22 +08:00
Fix working with async functions in the diff parser, fixes #56
This commit is contained in:
1 parent
0d37ff865c
commit
6c65aea47d
2 files changed
+19
No files matched your search
@@ -682,6 +682,8 @@ class _NodesTree(object):
|
||||
last = new_nodes[-1]
|
||||
if last.type == 'decorated':
|
||||
last = last.children[-1]
|
||||
if last.type in ('async_funcdef', 'async_stmt'):
|
||||
last = last.children[-1]
|
||||
last_line_offset_leaf = last.children[-2].get_last_leaf()
|
||||
assert last_line_offset_leaf == ':'
|
||||
else:
|
||||
|
||||
@@ -1267,3 +1267,20 @@ def test_x(differ):
|
||||
differ.parse(code2, copies=ANY, parsers=ANY, expect_error_leaves=True)
|
||||
differ.parse(code3, copies=ANY, parsers=ANY, expect_error_leaves=True)
|
||||
differ.parse(code1, copies=1)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 5), reason="Async starts working in 3.5")
|
||||
def test_async_copy(differ):
|
||||
code1 = dedent('''\
|
||||
async def main():
|
||||
x = 3
|
||||
print(
|
||||
''')
|
||||
code2 = dedent('''\
|
||||
async def main():
|
||||
x = 3
|
||||
print()
|
||||
''')
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, copies=1, parsers=1)
|
||||
differ.parse(code1, copies=1, parsers=1, expect_error_leaves=True)
|
||||
Reference in new issue
Block a user