diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-01-30 20:14:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-30 20:14:38 (GMT) |
commit | 3adac4126d659e1d42acf4625dedc8d92eb1c6c8 (patch) | |
tree | 0f14264976da684414e67bb3a45b880684b7c838 /Lib/test | |
parent | 626e2cc123f3540369b97e63e5efc90c3fd28b2c (diff) | |
download | cpython-3adac4126d659e1d42acf4625dedc8d92eb1c6c8.zip cpython-3adac4126d659e1d42acf4625dedc8d92eb1c6c8.tar.gz cpython-3adac4126d659e1d42acf4625dedc8d92eb1c6c8.tar.bz2 |
gh-101229: Add tests for aliases of imported names (GH-101230)
(cherry picked from commit 28db978d7f134edf6c86f21c42e15003511e7e9b)
Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_ast.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 55a3e6b..36fdb49 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -355,6 +355,24 @@ class AST_Tests(unittest.TestCase): self.assertEqual(alias.col_offset, 16) self.assertEqual(alias.end_col_offset, 17) + im = ast.parse("from bar import y as z").body[0] + alias = im.names[0] + self.assertEqual(alias.name, "y") + self.assertEqual(alias.asname, "z") + self.assertEqual(alias.lineno, 1) + self.assertEqual(alias.end_lineno, 1) + self.assertEqual(alias.col_offset, 16) + self.assertEqual(alias.end_col_offset, 22) + + im = ast.parse("import bar as foo").body[0] + alias = im.names[0] + self.assertEqual(alias.name, "bar") + self.assertEqual(alias.asname, "foo") + self.assertEqual(alias.lineno, 1) + self.assertEqual(alias.end_lineno, 1) + self.assertEqual(alias.col_offset, 7) + self.assertEqual(alias.end_col_offset, 17) + def test_base_classes(self): self.assertTrue(issubclass(ast.For, ast.stmt)) self.assertTrue(issubclass(ast.Name, ast.expr)) |