forked from VimPlug/jedi
tests for class/func name positions
This commit is contained in:
@@ -371,8 +371,7 @@ class SubModule(Scope, Module):
|
|||||||
string = re.sub('\.[a-z]+-\d{2}[mud]{0,3}$', '', r.group(1))
|
string = re.sub('\.[a-z]+-\d{2}[mud]{0,3}$', '', r.group(1))
|
||||||
# positions are not real therefore choose (0, 0)
|
# positions are not real therefore choose (0, 0)
|
||||||
names = [(string, (0, 0))]
|
names = [(string, (0, 0))]
|
||||||
self._name = Name(self, names, (0, 0), (0, 0),
|
self._name = Name(self, names, (0, 0), (0, 0), self.use_as_parent)
|
||||||
self.use_as_parent)
|
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
def is_builtin(self):
|
def is_builtin(self):
|
||||||
|
|||||||
@@ -45,6 +45,22 @@ class TestCallAndName():
|
|||||||
assert call.type == pr.Call.STRING
|
assert call.type == pr.Call.STRING
|
||||||
assert call.name == 'hello'
|
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():
|
def test_module():
|
||||||
module = Parser('asdf', 'example.py', no_docstr=True).module
|
module = Parser('asdf', 'example.py', no_docstr=True).module
|
||||||
name = module.name
|
name = module.name
|
||||||
|
|||||||
Reference in New Issue
Block a user