mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
updated/added import test (nested structures)
This commit is contained in:
@@ -5,6 +5,7 @@ import evaluate
|
|||||||
import modules
|
import modules
|
||||||
import debug
|
import debug
|
||||||
import imports
|
import imports
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class NotFoundError(Exception):
|
class NotFoundError(Exception):
|
||||||
@@ -122,7 +123,10 @@ class Definition(object):
|
|||||||
elif isinstance(d, (evaluate.Function, evaluate.parsing.Function)):
|
elif isinstance(d, (evaluate.Function, evaluate.parsing.Function)):
|
||||||
d = 'def ' + str(d.name)
|
d = 'def ' + str(d.name)
|
||||||
elif isinstance(d, evaluate.parsing.Module):
|
elif isinstance(d, evaluate.parsing.Module):
|
||||||
d = 'module ' + str(d.path)
|
p = str(d.path)
|
||||||
|
# only show module name
|
||||||
|
p = re.sub(r'^.*?([\w\d]+)(/__init__)?.py$', r'\1', p)
|
||||||
|
d = 'module ' + p
|
||||||
else:
|
else:
|
||||||
d = d.get_code().replace('\n', '')
|
d = d.get_code().replace('\n', '')
|
||||||
return d
|
return d
|
||||||
|
|||||||
@@ -67,3 +67,18 @@ def c():
|
|||||||
c
|
c
|
||||||
#! 0 ['def c']
|
#! 0 ['def c']
|
||||||
c()
|
c()
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# imports
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
#! ['module import_tree']
|
||||||
|
import import_tree
|
||||||
|
|
||||||
|
#! ['module mod1']
|
||||||
|
import import_tree.mod1
|
||||||
|
|
||||||
|
#! ['module mod1']
|
||||||
|
from import_tree import mod1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1
test/completion/import_tree/__init__.py
Normal file
1
test/completion/import_tree/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
a = ""
|
||||||
1
test/completion/import_tree/mod1.py
Normal file
1
test/completion/import_tree/mod1.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
a = 1
|
||||||
@@ -1,3 +1,39 @@
|
|||||||
|
# -----------------
|
||||||
|
# own structure
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
# do separate scopes
|
||||||
|
def scope_basic():
|
||||||
|
from import_tree import mod1
|
||||||
|
|
||||||
|
#? int()
|
||||||
|
mod1.a
|
||||||
|
|
||||||
|
#? []
|
||||||
|
import_tree.a
|
||||||
|
|
||||||
|
#? []
|
||||||
|
import_tree.mod1
|
||||||
|
|
||||||
|
import import_tree
|
||||||
|
#? str()
|
||||||
|
import_tree.a
|
||||||
|
|
||||||
|
#? []
|
||||||
|
import_tree.mod1
|
||||||
|
|
||||||
|
def scope_nested():
|
||||||
|
import import_tree.mod1
|
||||||
|
|
||||||
|
#? str()
|
||||||
|
import_tree.a
|
||||||
|
|
||||||
|
#? ['mod1']
|
||||||
|
import_tree.mod1
|
||||||
|
|
||||||
|
#? int()
|
||||||
|
import_tree.mod1.a
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# std lib modules
|
# std lib modules
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
3
test/completion/thirdparty/pylab.py
vendored
3
test/completion/thirdparty/pylab.py
vendored
@@ -2,8 +2,9 @@ import pylab
|
|||||||
pylab.
|
pylab.
|
||||||
|
|
||||||
# two gotos
|
# two gotos
|
||||||
#! ['module /usr/lib/python2.7/dist-packages/numpy/__init__.py']
|
#! ['module numpy']
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
#! ['module random']
|
#! ['module random']
|
||||||
import numpy.random
|
import numpy.random
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user