Fix instance docstring

This commit is contained in:
micbou
2017-07-13 01:42:09 +02:00
committed by Dave Halter
parent f5248250d8
commit 175e57214e
2 changed files with 20 additions and 0 deletions

View File

@@ -197,6 +197,11 @@ class CompiledInstance(AbstractInstanceContext):
class TreeInstance(AbstractInstanceContext):
def __init__(self, evaluator, parent_context, class_context, var_args):
super(TreeInstance, self).__init__(evaluator, parent_context,
class_context, var_args)
self.tree_node = class_context.tree_node
@property
def name(self):
return filters.ContextName(self, self.class_context.name.tree_name)

View File

@@ -22,6 +22,21 @@ class TestDocstring(unittest.TestCase):
func""").goto_definitions()
self.assertEqual(defs[0].docstring(), 'func()\n\nDocstring of `func`.')
def test_class_doc(self):
defs = jedi.Script("""
class TestClass():
'''Docstring of `TestClass`.'''
TestClass""").goto_definitions()
self.assertEqual(defs[0].docstring(), 'Docstring of `TestClass`.')
def test_instance_doc(self):
defs = jedi.Script("""
class TestClass():
'''Docstring of `TestClass`.'''
tc = TestClass()
tc""").goto_definitions()
self.assertEqual(defs[0].docstring(), 'Docstring of `TestClass`.')
@unittest.skip('need evaluator class for that')
def test_attribute_docstring(self):
defs = jedi.Script("""