mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
37 lines
975 B
Python
37 lines
975 B
Python
from jedi._compatibility import builtins
|
|
from jedi.parser.representation import Function
|
|
from jedi.evaluate import compiled
|
|
from jedi.evaluate import Evaluator
|
|
|
|
|
|
def test_simple():
|
|
e = Evaluator()
|
|
bltn = compiled.PyObject(builtins)
|
|
obj = compiled.PyObject('_str_', bltn)
|
|
upper = e.find_types(obj, 'upper')
|
|
assert len(upper) == 1
|
|
objs = list(e.execute(upper[0]))
|
|
assert len(objs) == 1
|
|
assert objs[0].obj is str
|
|
|
|
|
|
def test_fake_loading():
|
|
assert isinstance(compiled.create(next), Function)
|
|
|
|
string = compiled.builtin.get_subscope_by_name('str')
|
|
from_name = compiled._create_from_name(compiled.builtin, string, '__init__')
|
|
assert isinstance(from_name, Function)
|
|
|
|
|
|
def test_fake_docstr():
|
|
assert compiled.create(next).docstr == next.__doc__
|
|
|
|
|
|
def test_parse_function_doc_illegal_docstr():
|
|
docstr = """
|
|
test_func(o
|
|
|
|
doesn't have a closing bracket.
|
|
"""
|
|
assert ('', '') == compiled._parse_function_doc(docstr)
|