From 105bb2b1ca9d76d377ed24a10bc7ff0c05a219f3 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 24 May 2013 19:43:23 +0200 Subject: [PATCH] ModuleWithCursor.get_path_until_cursor cannot handle "\" It raises: IndexError: string index out of range --- test/test_regression.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_regression.py b/test/test_regression.py index e44afb8d..1e72cadf 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -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):