mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 23:04:48 +08:00
21 lines
876 B
Python
21 lines
876 B
Python
import jedi
|
|
import sys
|
|
from os.path import dirname, join
|
|
|
|
def test_namespace_package():
|
|
sys.path.insert(0, join(dirname(__file__), 'namespace_package/ns1'))
|
|
sys.path.insert(1, join(dirname(__file__), 'namespace_package/ns2'))
|
|
try:
|
|
assert jedi.Script('from pkg import ns1_file').goto_definitions()
|
|
assert jedi.Script('from pkg import ns2_file').goto_definitions()
|
|
assert not jedi.Script('from pkg import ns3_file').goto_definitions()
|
|
|
|
completions = jedi.Script('from pkg import ').completions()
|
|
names = [str(c.name) for c in completions] # str because of unicode
|
|
compare = ['foo', 'ns1_file', 'ns1_folder', 'ns2_folder', 'ns2_file']
|
|
# must at least contain these items, other items are not important
|
|
assert not (set(compare) - set(names))
|
|
finally:
|
|
sys.path.pop(0)
|
|
sys.path.pop(0)
|