mirror of
https://github.com/davidhalter/jedi.git
synced 2026-10-02 23:43:45 +08:00
Test parents a bit better
This commit is contained in:
1 parent
63a9418bd5
commit
0202d4ed0a
1 file changed
+17
-3
@@ -277,10 +277,24 @@ def test_parent_on_function(Script):
|
||||
|
||||
|
||||
def test_parent_on_completion(Script):
|
||||
parent = Script(dedent('''\
|
||||
script = Script(dedent('''\
|
||||
class Foo():
|
||||
def bar(): pass
|
||||
Foo().bar''')).complete()[0].parent()
|
||||
def bar(name): name
|
||||
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.type == 'class'
|
||||
|
||||
|
||||
Reference in new issue
Block a user