mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-11 16:21:51 +08:00
Fix Definition.get_definitions
This commit is contained in:
@@ -364,7 +364,7 @@ class Definition(BaseDefinition):
|
|||||||
|
|
||||||
:rtype: list of Definition
|
:rtype: list of Definition
|
||||||
"""
|
"""
|
||||||
return get_definitions(self._parser.scope)
|
return get_definitions(self.definition)
|
||||||
|
|
||||||
|
|
||||||
def get_definitions(scope):
|
def get_definitions(scope):
|
||||||
|
|||||||
@@ -425,6 +425,20 @@ class TestGetDefinitions(TestBase):
|
|||||||
assert definitions[1].names == ['b']
|
assert definitions[1].names == ['b']
|
||||||
assert definitions[2].names == []
|
assert definitions[2].names == []
|
||||||
|
|
||||||
|
def test_nested_definitions(self):
|
||||||
|
definitions = api.get_definitions("""
|
||||||
|
class Class:
|
||||||
|
def f():
|
||||||
|
pass
|
||||||
|
def g():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
assert len(definitions) == 1
|
||||||
|
assert definitions[0].names == ['Class']
|
||||||
|
subdefinitions = definitions[0].get_definitions()
|
||||||
|
assert subdefinitions[0].names == ['f']
|
||||||
|
assert subdefinitions[1].names == ['g']
|
||||||
|
|
||||||
|
|
||||||
class TestSpeed(TestBase):
|
class TestSpeed(TestBase):
|
||||||
def _check_speed(time_per_run, number=4, run_warm=True):
|
def _check_speed(time_per_run, number=4, run_warm=True):
|
||||||
|
|||||||
Reference in New Issue
Block a user