1
0
forked from VimPlug/jedi

@property now returns Name.type == 'property', fixes muffinmad/anakin-language-server#15

This commit is contained in:
Dave Halter
2020-07-20 01:20:24 +02:00
parent 7281302281
commit 784e965d3a
7 changed files with 57 additions and 3 deletions

View File

@@ -373,6 +373,34 @@ def test_type_II(Script):
assert c.type == 'keyword'
@pytest.mark.parametrize(
'added_code, expected_type, expected_infer_type', [
('Foo().x', 'property', 'instance'),
('Foo.x', 'property', 'property'),
('Foo().y', 'function', 'function'),
('Foo.y', 'function', 'function'),
('Foo().z', 'function', 'function'),
('Foo.z', 'function', 'function'),
]
)
def test_class_types(goto_or_help_or_infer, added_code, expected_type,
expected_infer_type):
code = dedent('''\
class Foo:
@property
def x(self): return 1
@staticmethod
def y(self): ...
@classmethod
def z(self): ...
''')
d, = goto_or_help_or_infer(code + added_code)
if goto_or_help_or_infer.type == 'infer':
assert d.type == expected_infer_type
else:
assert d.type == expected_type
"""
This tests the BaseName.goto function, not the jedi
function. They are not really different in functionality, but really