mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-20 20:41:13 +08:00
Test parents a bit better
This commit is contained in:
@@ -277,10 +277,24 @@ def test_parent_on_function(Script):
|
|||||||
|
|
||||||
|
|
||||||
def test_parent_on_completion(Script):
|
def test_parent_on_completion(Script):
|
||||||
parent = Script(dedent('''\
|
script = Script(dedent('''\
|
||||||
class Foo():
|
class Foo():
|
||||||
def bar(): pass
|
def bar(name): name
|
||||||
Foo().bar''')).complete()[0].parent()
|
Foo().bar'''))
|
||||||
|
|
||||||
|
bar, = script.complete()
|
||||||
|
parent = bar.parent()
|
||||||
|
assert parent.name == 'Foo'
|
||||||
|
assert parent.type == 'class'
|
||||||
|
|
||||||
|
param, = script.goto(line=2)
|
||||||
|
parent = param.parent()
|
||||||
|
assert parent.name == 'Foo'
|
||||||
|
assert parent.type == 'class'
|
||||||
|
|
||||||
|
name, = [d for d in script.names(all_scopes=True, references=True)
|
||||||
|
if d.name == 'name' and d.type == 'statement']
|
||||||
|
parent = param.parent()
|
||||||
assert parent.name == 'Foo'
|
assert parent.name == 'Foo'
|
||||||
assert parent.type == 'class'
|
assert parent.type == 'class'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user