From a68e35c895ec2bb16e8ec4df34ea417fc2772b6c Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Sun, 9 Sep 2018 22:49:06 +0100 Subject: [PATCH] Comprehension parent --- test/test_api/test_classes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index d320966a..788bc4e7 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -289,6 +289,20 @@ def test_parent_on_completion(Script): assert parent.type == 'class' +def test_parent_on_comprehension(): + ns = jedi.names('''\ + def spam(): + return [i for i in range(5)] + ''', all_scopes=True) + + assert [name.name for name in ns] == ['spam', 'i'] + + assert ns[0].parent().name == '' + assert ns[0].parent().type == 'module' + assert ns[1].parent().name == 'spam' + assert ns[1].parent().type == 'function' + + def test_type(Script): for c in Script('a = [str()]; a[0].').completions(): if c.name == '__class__':