mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +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
|
||||
"""
|
||||
|
||||
# python2.5 compatibility
|
||||
try:
|
||||
next
|
||||
@@ -138,7 +139,6 @@ class ArrayElement(object):
|
||||
@property
|
||||
def parent(self):
|
||||
raise NotImplementedError("This shouldn't happen")
|
||||
return
|
||||
|
||||
@property
|
||||
def returns(self):
|
||||
|
||||
@@ -58,8 +58,6 @@ class FileWithCursor(modules.File):
|
||||
close_brackets = [')', ']', '}']
|
||||
|
||||
gen = tokenize.generate_tokens(fetch_line)
|
||||
# TODO can happen: raise TokenError, ("EOF in multi-line statement"
|
||||
# where???
|
||||
string = ''
|
||||
level = 0
|
||||
for token_type, tok, start, end, line in gen:
|
||||
@@ -199,6 +197,9 @@ def complete(source, row, column, source_path):
|
||||
for s in scopes:
|
||||
completions += s.get_defined_names()
|
||||
|
||||
# remove duplicates
|
||||
completions = list(set(completions))
|
||||
|
||||
needs_dot = not dot and path
|
||||
completions = [Completion(c, needs_dot, len(like)) for c in completions
|
||||
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;
|
||||
abc = [1,2+3]; abc[0].
|
||||
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}
|
||||
is_call = lambda: result.__class__ == Call
|
||||
is_call_or_close = lambda: is_call() or close_brackets
|
||||
|
||||
if isinstance(tok, Name) or token_type in [tokenize.STRING,
|
||||
tokenize.NUMBER]: # names
|
||||
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
|
||||
#? ['prefix']
|
||||
@@ -7,14 +25,13 @@ sys.prefix
|
||||
#? ['append']
|
||||
sys.path.append
|
||||
|
||||
|
||||
# --- builtin math ---
|
||||
|
||||
from math import *
|
||||
#? ['cos', 'cosh']
|
||||
cos
|
||||
|
||||
import os
|
||||
def func_with_import():
|
||||
import time
|
||||
return time
|
||||
|
||||
#? ['dirname']
|
||||
os.path.dirname
|
||||
#? ['sleep']
|
||||
func_with_import().sleep
|
||||
|
||||
@@ -39,11 +39,12 @@ def completion_test(source):
|
||||
print traceback.format_exc()
|
||||
fails += 1
|
||||
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]))
|
||||
if comp_str != correct:
|
||||
print 'Solution not correct, received %s, wanted %s' % \
|
||||
(comp_str, correct)
|
||||
#print [(c.name, c.name.parent) for c in completions]
|
||||
fails += 1
|
||||
correct = None
|
||||
tests += 1
|
||||
|
||||
Reference in New Issue
Block a user