ModuleWithCursor.get_path_until_cursor cannot handle "\"

It raises: IndexError: string index out of range
This commit is contained in:
Takafumi Arakaki
2013-05-24 19:43:23 +02:00
parent 788eeb9bd5
commit 105bb2b1ca

View File

@@ -395,6 +395,22 @@ class TestRegression(TestBase):
for c in s.get_commands():
self.assertEqual(c.execution.end_pos[1], i)
def test_backslash_continuation(self):
"""
Test that ModuleWithCursor.get_path_until_cursor handles continuation
"""
source = textwrap.dedent(r"""
x = 0
a = \
[1, 2, 3, 4, 5, 6, 7, 8, 9, x] # <-- here
""")
for (i, line) in enumerate(source.splitlines()):
if '<-- here' in line:
break
column = len(line) - len('] # <-- here')
defs = self.goto_definitions(source, (i + 1, column))
self.assertEqual([d.name for d in defs], ['int'])
class TestDocstring(TestBase):