mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
added import tests
This commit is contained in:
@@ -6,6 +6,7 @@ follow_statement -> follow_call -> follow_paths -> follow_path
|
|||||||
|
|
||||||
TODO include super classes
|
TODO include super classes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# python2.5 compatibility
|
# python2.5 compatibility
|
||||||
try:
|
try:
|
||||||
next
|
next
|
||||||
@@ -138,7 +139,6 @@ class ArrayElement(object):
|
|||||||
@property
|
@property
|
||||||
def parent(self):
|
def parent(self):
|
||||||
raise NotImplementedError("This shouldn't happen")
|
raise NotImplementedError("This shouldn't happen")
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def returns(self):
|
def returns(self):
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ class FileWithCursor(modules.File):
|
|||||||
close_brackets = [')', ']', '}']
|
close_brackets = [')', ']', '}']
|
||||||
|
|
||||||
gen = tokenize.generate_tokens(fetch_line)
|
gen = tokenize.generate_tokens(fetch_line)
|
||||||
# TODO can happen: raise TokenError, ("EOF in multi-line statement"
|
|
||||||
# where???
|
|
||||||
string = ''
|
string = ''
|
||||||
level = 0
|
level = 0
|
||||||
for token_type, tok, start, end, line in gen:
|
for token_type, tok, start, end, line in gen:
|
||||||
@@ -199,6 +197,9 @@ def complete(source, row, column, source_path):
|
|||||||
for s in scopes:
|
for s in scopes:
|
||||||
completions += s.get_defined_names()
|
completions += s.get_defined_names()
|
||||||
|
|
||||||
|
# remove duplicates
|
||||||
|
completions = list(set(completions))
|
||||||
|
|
||||||
needs_dot = not dot and path
|
needs_dot = not dot and path
|
||||||
completions = [Completion(c, needs_dot, len(like)) for c in completions
|
completions = [Completion(c, needs_dot, len(like)) for c in completions
|
||||||
if c.names[-1].lower().startswith(like.lower())]
|
if c.names[-1].lower().startswith(like.lower())]
|
||||||
|
|||||||
@@ -147,4 +147,4 @@ c = b().c3()
|
|||||||
1.0.fromhex(); import flask ; flsk = flask.Flask + flask.Request;
|
1.0.fromhex(); import flask ; flsk = flask.Flask + flask.Request;
|
||||||
abc = [1,2+3]; abc[0].
|
abc = [1,2+3]; abc[0].
|
||||||
import pylab; def add(a1,b1): nana = 1; return a1+b1
|
import pylab; def add(a1,b1): nana = 1; return a1+b1
|
||||||
abc = datetime; return [abc][0]. ;pylab.; add(1+2,2).
|
abc = datetime; return [abc][0]. ;pylab.; add(1+2,2).real
|
||||||
|
|||||||
@@ -570,6 +570,7 @@ class Statement(Simple):
|
|||||||
brackets = {'(': Array.EMPTY, '[': Array.LIST, '{': Array.SET}
|
brackets = {'(': Array.EMPTY, '[': Array.LIST, '{': Array.SET}
|
||||||
is_call = lambda: result.__class__ == Call
|
is_call = lambda: result.__class__ == Call
|
||||||
is_call_or_close = lambda: is_call() or close_brackets
|
is_call_or_close = lambda: is_call() or close_brackets
|
||||||
|
|
||||||
if isinstance(tok, Name) or token_type in [tokenize.STRING,
|
if isinstance(tok, Name) or token_type in [tokenize.STRING,
|
||||||
tokenize.NUMBER]: # names
|
tokenize.NUMBER]: # names
|
||||||
c_type = Call.NAME
|
c_type = Call.NAME
|
||||||
|
|||||||
@@ -1,4 +1,22 @@
|
|||||||
|
# -----------------
|
||||||
|
# std lib modules
|
||||||
|
# -----------------
|
||||||
|
import tokenize
|
||||||
|
#? ['tok_name']
|
||||||
|
tokenize.tok_name
|
||||||
|
|
||||||
|
from pyclbr import *
|
||||||
|
|
||||||
|
#? ['readmodule_ex']
|
||||||
|
readmodule_ex
|
||||||
|
import os
|
||||||
|
|
||||||
|
#? ['dirname']
|
||||||
|
os.path.dirname
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# builtins
|
||||||
|
# -----------------
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
#? ['prefix']
|
#? ['prefix']
|
||||||
@@ -7,14 +25,13 @@ sys.prefix
|
|||||||
#? ['append']
|
#? ['append']
|
||||||
sys.path.append
|
sys.path.append
|
||||||
|
|
||||||
|
|
||||||
# --- builtin math ---
|
|
||||||
|
|
||||||
from math import *
|
from math import *
|
||||||
#? ['cos', 'cosh']
|
#? ['cos', 'cosh']
|
||||||
cos
|
cos
|
||||||
|
|
||||||
import os
|
def func_with_import():
|
||||||
|
import time
|
||||||
|
return time
|
||||||
|
|
||||||
#? ['dirname']
|
#? ['sleep']
|
||||||
os.path.dirname
|
func_with_import().sleep
|
||||||
|
|||||||
@@ -39,11 +39,12 @@ def completion_test(source):
|
|||||||
print traceback.format_exc()
|
print traceback.format_exc()
|
||||||
fails += 1
|
fails += 1
|
||||||
else:
|
else:
|
||||||
# TODO remove sorted? completions should be sorted
|
# TODO remove sorted? completions should be sorted?
|
||||||
comp_str = str(sorted([str(c) for c in completions]))
|
comp_str = str(sorted([str(c) for c in completions]))
|
||||||
if comp_str != correct:
|
if comp_str != correct:
|
||||||
print 'Solution not correct, received %s, wanted %s' % \
|
print 'Solution not correct, received %s, wanted %s' % \
|
||||||
(comp_str, correct)
|
(comp_str, correct)
|
||||||
|
#print [(c.name, c.name.parent) for c in completions]
|
||||||
fails += 1
|
fails += 1
|
||||||
correct = None
|
correct = None
|
||||||
tests += 1
|
tests += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user