forked from VimPlug/jedi
Move the python parser tree.
This commit is contained in:
@@ -6,7 +6,7 @@ import jedi
|
||||
from jedi._compatibility import u, is_py3
|
||||
from jedi.parser import ParserWithRecovery
|
||||
from jedi.parser.python import parse, load_grammar
|
||||
from jedi.parser import tree as pt
|
||||
from jedi.parser.python import tree
|
||||
|
||||
|
||||
def test_user_statement_on_import():
|
||||
@@ -17,7 +17,7 @@ def test_user_statement_on_import():
|
||||
for pos in [(2, 1), (2, 4)]:
|
||||
p = parse(s)
|
||||
stmt = p.get_statement_for_position(pos)
|
||||
assert isinstance(stmt, pt.Import)
|
||||
assert isinstance(stmt, tree.Import)
|
||||
assert [str(n) for n in stmt.get_defined_names()] == ['time']
|
||||
|
||||
|
||||
@@ -41,19 +41,19 @@ class TestCallAndName():
|
||||
|
||||
def test_call_type(self):
|
||||
call = self.get_call('hello')
|
||||
assert isinstance(call, pt.Name)
|
||||
assert isinstance(call, tree.Name)
|
||||
|
||||
def test_literal_type(self):
|
||||
literal = self.get_call('1.0')
|
||||
assert isinstance(literal, pt.Literal)
|
||||
assert isinstance(literal, tree.Literal)
|
||||
assert type(literal.eval()) == float
|
||||
|
||||
literal = self.get_call('1')
|
||||
assert isinstance(literal, pt.Literal)
|
||||
assert isinstance(literal, tree.Literal)
|
||||
assert type(literal.eval()) == int
|
||||
|
||||
literal = self.get_call('"hello"')
|
||||
assert isinstance(literal, pt.Literal)
|
||||
assert isinstance(literal, tree.Literal)
|
||||
assert literal.eval() == 'hello'
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ def test_param_splitting():
|
||||
|
||||
|
||||
def test_unicode_string():
|
||||
s = pt.String(None, u('bö'), (0, 0))
|
||||
s = tree.String(None, u('bö'), (0, 0))
|
||||
assert repr(s) # Should not raise an Error!
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
from jedi._compatibility import u, unicode
|
||||
from jedi.parser.python import parse
|
||||
from jedi.parser import tree as pt
|
||||
from jedi.parser.python import tree
|
||||
|
||||
|
||||
class TestsFunctionAndLambdaParsing(object):
|
||||
@@ -34,14 +34,14 @@ class TestsFunctionAndLambdaParsing(object):
|
||||
@pytest.fixture()
|
||||
def expected(self, request, node):
|
||||
return request.keywords['expected']
|
||||
|
||||
|
||||
def test_name(self, node, expected):
|
||||
assert isinstance(node.name, pt.Name)
|
||||
assert isinstance(node.name, tree.Name)
|
||||
assert unicode(node.name) == u(expected['name'])
|
||||
|
||||
|
||||
def test_params(self, node, expected):
|
||||
assert isinstance(node.params, list)
|
||||
assert all(isinstance(x, pt.Param) for x in node.params)
|
||||
assert all(isinstance(x, tree.Param) for x in node.params)
|
||||
assert [unicode(x.name) for x in node.params] == [u(x) for x in expected['params']]
|
||||
|
||||
def test_is_generator(self, node, expected):
|
||||
|
||||
Reference in New Issue
Block a user