mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-09 13:32:20 +08:00
A lot more fixes - fix all evaluate integration tests.
This commit is contained in:
@@ -2,8 +2,8 @@ from textwrap import dedent
|
||||
|
||||
from jedi._compatibility import builtins, is_py3
|
||||
from jedi.parser import load_grammar
|
||||
from jedi.parser.tree import Function
|
||||
from jedi.evaluate import compiled, representation
|
||||
from jedi.evaluate import compiled, instance
|
||||
from jedi.evaluate.representation import FunctionContext
|
||||
from jedi.evaluate import Evaluator
|
||||
from jedi import Script
|
||||
|
||||
@@ -16,25 +16,24 @@ def test_simple():
|
||||
e = _evaluator()
|
||||
bltn = compiled.CompiledObject(e, builtins)
|
||||
obj = compiled.CompiledObject(e, '_str_', bltn)
|
||||
upper = e.find_types(obj, 'upper')
|
||||
assert len(upper) == 1
|
||||
objs = list(e.execute(list(upper)[0]))
|
||||
upper, = obj.py__getattribute__('upper')
|
||||
objs = list(upper.execute_evaluated())
|
||||
assert len(objs) == 1
|
||||
assert isinstance(objs[0], representation.Instance)
|
||||
assert isinstance(objs[0], instance.CompiledInstance)
|
||||
|
||||
|
||||
def test_fake_loading():
|
||||
e = _evaluator()
|
||||
assert isinstance(compiled.create(e, next), Function)
|
||||
assert isinstance(compiled.create(e, next), FunctionContext)
|
||||
|
||||
builtin = compiled.get_special_object(e, 'BUILTINS')
|
||||
string = builtin.get_subscope_by_name('str')
|
||||
string, = builtin.py__getattribute__('str')
|
||||
from_name = compiled._create_from_name(e, builtin, string, '__init__')
|
||||
assert isinstance(from_name, Function)
|
||||
assert isinstance(from_name, FunctionContext)
|
||||
|
||||
|
||||
def test_fake_docstr():
|
||||
assert compiled.create(_evaluator(), next).raw_doc == next.__doc__
|
||||
assert compiled.create(_evaluator(), next).get_node().raw_doc == next.__doc__
|
||||
|
||||
|
||||
def test_parse_function_doc_illegal_docstr():
|
||||
|
||||
@@ -10,7 +10,7 @@ def test_call_of_leaf_in_brackets():
|
||||
type(x)
|
||||
""")
|
||||
last_x = names(s, references=True, definitions=False)[-1]
|
||||
name = last_x._name
|
||||
name = last_x._name.tree_name
|
||||
|
||||
call = helpers.call_of_leaf(name)
|
||||
assert call == name
|
||||
|
||||
@@ -97,7 +97,7 @@ def test_not_importable_file():
|
||||
def test_import_unique():
|
||||
src = "import os; os.path"
|
||||
defs = jedi.Script(src, path='example.py').goto_definitions()
|
||||
defs = [d._definition for d in defs]
|
||||
defs = [d._name.parent_context for d in defs]
|
||||
assert len(defs) == len(set(defs))
|
||||
|
||||
|
||||
|
||||
@@ -49,16 +49,16 @@ def test_namespace_package():
|
||||
for c in script_with_path(source + '; x.').completions():
|
||||
if c.name == 'foo':
|
||||
completion = c
|
||||
solution = "statement: foo = '%s'" % solution
|
||||
solution = "foo = '%s'" % solution
|
||||
assert completion.description == solution
|
||||
|
||||
|
||||
def test_nested_namespace_package():
|
||||
CODE = 'from nested_namespaces.namespace.pkg import CONST'
|
||||
code = 'from nested_namespaces.namespace.pkg import CONST'
|
||||
|
||||
sys_path = [dirname(__file__)]
|
||||
|
||||
script = jedi.Script(sys_path=sys_path, source=CODE, line=1, column=45)
|
||||
script = jedi.Script(sys_path=sys_path, source=code, line=1, column=45)
|
||||
|
||||
result = script.goto_definitions()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user