Fix: Make the NodesStack to a NodesTree

This fixes an issue with positions that were doubled if the stack was closed too early.
This commit is contained in:
Dave Halter
2018-12-30 01:27:37 +01:00
parent 0ef4809377
commit e5fb1927bb
2 changed files with 104 additions and 79 deletions

View File

@@ -530,3 +530,33 @@ def test_end_newline_with_decorator(differ):
newline, first_stmt, second_stmt = suite.children
assert first_stmt.get_code() == ' import json\n'
assert second_stmt.get_code() == ' json.l\n'
def test_invalid_to_valid_nodes(differ):
code1 = dedent('''\
def a():
foo = 3
def b():
la = 3
else:
la
return
foo
base
''')
code2 = dedent('''\
def a():
foo = 3
def b():
la = 3
if foo:
latte = 3
else:
la
return
foo
base
''')
differ.initialize(code1)
differ.parse(code2, parsers=2, copies=3)