From c37515f9383b70ad6d08ac4d1ce86e1483bbf015 Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 3 May 2013 15:01:30 +0430 Subject: [PATCH] included test from #162 (seems to be working), fixes #162 --- jedi/parsing_representation.py | 2 +- test/test_regression.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index b286b4a1..0e0641c2 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -349,8 +349,8 @@ class SubModule(Scope, Module): :param name: The name of the global. :type name: Name """ - self.global_vars.append(name) # set no parent here, because globals are not defined in this scope. + self.global_vars.append(name) def get_set_vars(self): n = super(SubModule, self).get_set_vars() diff --git a/test/test_regression.py b/test/test_regression.py index 5b6eac3b..2b1116bb 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -364,6 +364,21 @@ class TestRegression(TestBase): words = [c.word for c in self.complete(s)] assert 'start' in words + def test_no_statement_parent(self): + source = textwrap.dedent(""" + def f(): + pass + + class C: + pass + + variable = f or C""") + lines = source.splitlines() + defs = self.definition(source, (len(lines), 3)) + defs = sorted(defs, key=lambda d: d.line) + self.assertEqual([d.description for d in defs], + ['def f', 'class C']) + class TestDocstring(TestBase):