diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index e3b8f2ee..70d02346 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -371,8 +371,7 @@ class SubModule(Scope, Module): string = re.sub('\.[a-z]+-\d{2}[mud]{0,3}$', '', r.group(1)) # positions are not real therefore choose (0, 0) names = [(string, (0, 0))] - self._name = Name(self, names, (0, 0), (0, 0), - self.use_as_parent) + self._name = Name(self, names, (0, 0), (0, 0), self.use_as_parent) return self._name def is_builtin(self): diff --git a/test/test_parsing.py b/test/test_parsing.py index 5dc49aac..d8623f2e 100644 --- a/test/test_parsing.py +++ b/test/test_parsing.py @@ -45,6 +45,22 @@ class TestCallAndName(): assert call.type == pr.Call.STRING assert call.name == 'hello' +class TestSubscopes(): + def get_sub(self, source): + return Parser(source).module.subscopes[0] + + def test_subscope_names(self): + name = self.get_sub('class Foo: pass').name + assert name.start_pos == (1, len('class ')) + assert name.end_pos == (1, len('class Foo')) + assert str(name) == 'Foo' + + name = self.get_sub('def foo(): pass').name + assert name.start_pos == (1, len('def ')) + assert name.end_pos == (1, len('def foo')) + assert str(name) == 'foo' + + def test_module(): module = Parser('asdf', 'example.py', no_docstr=True).module name = module.name