1
0
forked from VimPlug/jedi

Merge branch 'get_code_fidelity' of git://github.com/ganwell/jedi into ganwell

This commit is contained in:
Dave Halter
2014-02-12 11:09:08 +01:00
8 changed files with 173 additions and 21 deletions

View File

@@ -19,12 +19,16 @@ 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__')
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__
assert compiled.create(next).docstr.as_string() == next.__doc__
def test_parse_function_doc_illegal_docstr():

46
test/test_get_code.py Normal file
View File

@@ -0,0 +1,46 @@
import jedi.parser as parser
import difflib
code_basic_features = '''
"""A mod docstring"""
def a_function(a_argument, a_default = "default"):
"""A func docstring"""
a_result = 3 * a_argument
print(a_result) # a comment
b = """
from
to""" + "huhu"
if a_default == "default":
return str(a_result)
else
return None
'''
def diff_code_assert(a, b, n=4):
if a != b:
diff = "\n".join(difflib.unified_diff(
a.splitlines(),
b.splitlines(),
n=n,
lineterm=""
))
assert False, "Code does not match:\n%s\n\ncreated code:\n%s" % (
diff,
b
)
pass
def test_basic_parsing():
"""Validate the parsing features"""
prs = parser.Parser(code_basic_features)
# diff_code_assert(
# code_basic_features,
# prs.top_module.get_code2()
# )