forked from VimPlug/jedi
Add tests for Script.definition when in function call
This commit is contained in:
@@ -10,6 +10,7 @@ import time
|
|||||||
import functools
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
|
import textwrap
|
||||||
|
|
||||||
from base import TestBase, cwd_at
|
from base import TestBase, cwd_at
|
||||||
|
|
||||||
@@ -95,6 +96,31 @@ class TestRegression(TestBase):
|
|||||||
if not is_py25:
|
if not is_py25:
|
||||||
assert len(r[0].doc) > 100
|
assert len(r[0].doc) > 100
|
||||||
|
|
||||||
|
def definition_when_in_function_call(self, pre_cursor, post_cursor=''):
|
||||||
|
source = textwrap.dedent("""
|
||||||
|
def f():
|
||||||
|
pass
|
||||||
|
%s%s""" % (pre_cursor, post_cursor))
|
||||||
|
lines = source.splitlines()
|
||||||
|
pos = (len(lines), len(pre_cursor))
|
||||||
|
return list(self.definition(source, pos))
|
||||||
|
|
||||||
|
def test_definition_when_in_function_call_right_after_open_paren(self):
|
||||||
|
defs = self.definition_when_in_function_call('f(')
|
||||||
|
self.assertEqual(defs[0].description, 'def f')
|
||||||
|
|
||||||
|
def test_definition_when_in_function_call_after_open_paren_and_space(self):
|
||||||
|
defs = self.definition_when_in_function_call('f( ')
|
||||||
|
self.assertEqual(defs[0].description, 'def f')
|
||||||
|
|
||||||
|
def test_definition_when_in_function_call_right_after_comma(self):
|
||||||
|
defs = self.definition_when_in_function_call('f(1,')
|
||||||
|
self.assertEqual(defs[0].description, 'def f')
|
||||||
|
|
||||||
|
def test_definition_when_in_function_call_after_comma_and_space(self):
|
||||||
|
defs = self.definition_when_in_function_call('f(1, ')
|
||||||
|
self.assertEqual(defs[0].description, 'def f')
|
||||||
|
|
||||||
def test_function_call_signature(self):
|
def test_function_call_signature(self):
|
||||||
defs = self.definition("""
|
defs = self.definition("""
|
||||||
def f(x, y=1, z='a'):
|
def f(x, y=1, z='a'):
|
||||||
|
|||||||
Reference in New Issue
Block a user