#10869: do not visit root node twice in ast.increment_lineno().

This commit is contained in:
Georg Brandl 2011-01-09 07:38:51 +00:00
parent 5b2d9ddf69
commit 619e7ba814
5 changed files with 17 additions and 8 deletions

View file

@ -264,6 +264,13 @@ class ASTHelpers_Test(unittest.TestCase):
'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, '
'col_offset=0))'
)
# issue10869: do not increment lineno of root twice
self.assertEqual(ast.increment_lineno(src.body, n=3), src.body)
self.assertEqual(ast.dump(src, include_attributes=True),
'Expression(body=BinOp(left=Num(n=1, lineno=4, col_offset=0), '
'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, '
'col_offset=0))'
)
def test_iter_fields(self):
node = ast.parse('foo()', mode='eval')