diff options
author | Batuhan Taskaya <isidentical@gmail.com> | 2022-11-22 10:41:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 10:41:14 (GMT) |
commit | 1acdfec359fdf3db936168480be0f4157273c200 (patch) | |
tree | ecc1f515cee2ebfe1e5f740af7b828775a8fd7e2 /Lib/test | |
parent | bc3a11d21ddef28047b18c0f6a5068fa9fb16da2 (diff) | |
download | cpython-1acdfec359fdf3db936168480be0f4157273c200.zip cpython-1acdfec359fdf3db936168480be0f4157273c200.tar.gz cpython-1acdfec359fdf3db936168480be0f4157273c200.tar.bz2 |
gh-99341: Cover type ignore nodes when incrementing line numbers (GH-99422)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_ast.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index b346441..773fba8 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -1036,6 +1036,18 @@ Module( self.assertEqual(ast.increment_lineno(src).lineno, 2) self.assertIsNone(ast.increment_lineno(src).end_lineno) + def test_increment_lineno_on_module(self): + src = ast.parse(dedent("""\ + a = 1 + b = 2 # type: ignore + c = 3 + d = 4 # type: ignore@tag + """), type_comments=True) + ast.increment_lineno(src, n=5) + self.assertEqual(src.type_ignores[0].lineno, 7) + self.assertEqual(src.type_ignores[1].lineno, 9) + self.assertEqual(src.type_ignores[1].tag, '@tag') + def test_iter_fields(self): node = ast.parse('foo()', mode='eval') d = dict(ast.iter_fields(node.body)) |