summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fstring.py
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-01-13 04:05:13 (GMT)
committerINADA Naoki <methane@users.noreply.github.com>2019-01-13 04:05:13 (GMT)
commit995d9b92979768125ced4da3a56f755bcdf80f6e (patch)
tree2184ab1771b87883a92391f41229a12ce4cbd9d3 /Lib/test/test_fstring.py
parent1cffd0eed313011c0c2bb071c8affeb4a7ed05c7 (diff)
downloadcpython-995d9b92979768125ced4da3a56f755bcdf80f6e.zip
cpython-995d9b92979768125ced4da3a56f755bcdf80f6e.tar.gz
cpython-995d9b92979768125ced4da3a56f755bcdf80f6e.tar.bz2
bpo-16806: Fix `lineno` and `col_offset` for multi-line string tokens (GH-10021)
Diffstat (limited to 'Lib/test/test_fstring.py')
-rw-r--r--Lib/test/test_fstring.py32
1 files changed, 13 insertions, 19 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index 9e45770..9d60be3 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -270,10 +270,7 @@ f'{a * x()} {a * x()} {a * x()}'
self.assertEqual(binop.right.col_offset, 7) # FIXME: this is wrong
def test_ast_line_numbers_multiline_fstring(self):
- # FIXME: This test demonstrates invalid behavior due to JoinedStr's
- # immediate child nodes containing the wrong lineno. The enclosed
- # expressions have valid line information and column offsets.
- # See bpo-16806 and bpo-30465 for details.
+ # See bpo-30465 for details.
expr = """
a = 10
f'''
@@ -298,19 +295,16 @@ non-important content
self.assertEqual(type(t.body[1].value.values[1]), ast.FormattedValue)
self.assertEqual(type(t.body[1].value.values[2]), ast.Constant)
self.assertEqual(type(t.body[1].value.values[2].value), str)
- # NOTE: the following invalid behavior is described in bpo-16806.
- # - line number should be the *first* line (3), not the *last* (8)
- # - column offset should not be -1
- self.assertEqual(t.body[1].lineno, 8)
- self.assertEqual(t.body[1].value.lineno, 8)
- self.assertEqual(t.body[1].value.values[0].lineno, 8)
- self.assertEqual(t.body[1].value.values[1].lineno, 8)
- self.assertEqual(t.body[1].value.values[2].lineno, 8)
- self.assertEqual(t.body[1].col_offset, -1)
- self.assertEqual(t.body[1].value.col_offset, -1)
- self.assertEqual(t.body[1].value.values[0].col_offset, -1)
- self.assertEqual(t.body[1].value.values[1].col_offset, -1)
- self.assertEqual(t.body[1].value.values[2].col_offset, -1)
+ self.assertEqual(t.body[1].lineno, 3)
+ self.assertEqual(t.body[1].value.lineno, 3)
+ self.assertEqual(t.body[1].value.values[0].lineno, 3)
+ self.assertEqual(t.body[1].value.values[1].lineno, 3)
+ self.assertEqual(t.body[1].value.values[2].lineno, 3)
+ self.assertEqual(t.body[1].col_offset, 0)
+ self.assertEqual(t.body[1].value.col_offset, 0)
+ self.assertEqual(t.body[1].value.values[0].col_offset, 0)
+ self.assertEqual(t.body[1].value.values[1].col_offset, 0)
+ self.assertEqual(t.body[1].value.values[2].col_offset, 0)
# NOTE: the following lineno information and col_offset is correct for
# expressions within FormattedValues.
binop = t.body[1].value.values[1].value
@@ -321,8 +315,8 @@ non-important content
self.assertEqual(binop.lineno, 4)
self.assertEqual(binop.left.lineno, 4)
self.assertEqual(binop.right.lineno, 6)
- self.assertEqual(binop.col_offset, 3)
- self.assertEqual(binop.left.col_offset, 3)
+ self.assertEqual(binop.col_offset, 4)
+ self.assertEqual(binop.left.col_offset, 4)
self.assertEqual(binop.right.col_offset, 7)
def test_docstring(self):