summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ast.py
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2019-12-18 00:20:55 (GMT)
committerPablo Galindo <Pablogsal@gmail.com>2019-12-18 00:20:55 (GMT)
commit50d4f12958bf806a4e1a1021d70cfd5d448c5cba (patch)
treea72061a8d4f0137b6094d4fdd7a9575065289d8a /Lib/test/test_ast.py
parenta9d0a6a1b932752873e04714c5dda707729078e4 (diff)
downloadcpython-50d4f12958bf806a4e1a1021d70cfd5d448c5cba.zip
cpython-50d4f12958bf806a4e1a1021d70cfd5d448c5cba.tar.gz
cpython-50d4f12958bf806a4e1a1021d70cfd5d448c5cba.tar.bz2
bpo-39080: Starred Expression's column offset fix when inside a CALL (GH-17645)
Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r--Lib/test/test_ast.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index cd35f96..51a7c1a 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -209,6 +209,8 @@ eval_tests = [
"1 < 2 < 3",
# Call
"f(1,2,c=3,*d,**e)",
+ # Call with multi-character starred
+ "f(*[0, 1])",
# Call with a generator argument
"f(a for a in b)",
# Num
@@ -877,6 +879,12 @@ Module(
self.assertEqual(elif_stmt.lineno, 3)
self.assertEqual(elif_stmt.col_offset, 0)
+ def test_starred_expr_end_position_within_call(self):
+ node = ast.parse('f(*[0, 1])')
+ starred_expr = node.body[0].value.args[0]
+ self.assertEqual(starred_expr.end_lineno, 1)
+ self.assertEqual(starred_expr.end_col_offset, 9)
+
def test_literal_eval(self):
self.assertEqual(ast.literal_eval('[1, 2, 3]'), [1, 2, 3])
self.assertEqual(ast.literal_eval('{"foo": 42}'), {"foo": 42})
@@ -1930,6 +1938,7 @@ eval_results = [
('Expression', ('GeneratorExp', (1, 0), ('Tuple', (1, 1), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('List', (1, 11), [('Name', (1, 12), 'a', ('Store',)), ('Name', (1, 14), 'b', ('Store',))], ('Store',)), ('Name', (1, 20), 'c', ('Load',)), [], 0)])),
('Expression', ('Compare', (1, 0), ('Constant', (1, 0), 1, None), [('Lt',), ('Lt',)], [('Constant', (1, 4), 2, None), ('Constant', (1, 8), 3, None)])),
('Expression', ('Call', (1, 0), ('Name', (1, 0), 'f', ('Load',)), [('Constant', (1, 2), 1, None), ('Constant', (1, 4), 2, None), ('Starred', (1, 10), ('Name', (1, 11), 'd', ('Load',)), ('Load',))], [('keyword', 'c', ('Constant', (1, 8), 3, None)), ('keyword', None, ('Name', (1, 15), 'e', ('Load',)))])),
+('Expression', ('Call', (1, 0), ('Name', (1, 0), 'f', ('Load',)), [('Starred', (1, 2), ('List', (1, 3), [('Constant', (1, 4), 0, None), ('Constant', (1, 7), 1, None)], ('Load',)), ('Load',))], [])),
('Expression', ('Call', (1, 0), ('Name', (1, 0), 'f', ('Load',)), [('GeneratorExp', (1, 1), ('Name', (1, 2), 'a', ('Load',)), [('comprehension', ('Name', (1, 8), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Load',)), [], 0)])], [])),
('Expression', ('Constant', (1, 0), 10, None)),
('Expression', ('Constant', (1, 0), 'string', None)),