mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-02 23:15:27 +08:00
Merge branch 'dev' of github.com:davidhalter/jedi into dev
This commit is contained in:
@@ -4,7 +4,7 @@ import sys
|
||||
import pytest
|
||||
|
||||
import jedi
|
||||
from jedi._compatibility import find_module_py33
|
||||
from jedi._compatibility import find_module_py33, find_module
|
||||
from ..helpers import cwd_at
|
||||
|
||||
|
||||
@@ -14,6 +14,44 @@ def test_find_module_py33():
|
||||
assert find_module_py33('_io') == (None, '_io', False)
|
||||
|
||||
|
||||
def test_find_module_package():
|
||||
file, path, is_package = find_module('json')
|
||||
assert file is None
|
||||
assert path.endswith('json')
|
||||
assert is_package is True
|
||||
|
||||
|
||||
def test_find_module_not_package():
|
||||
file, path, is_package = find_module('io')
|
||||
assert file is not None
|
||||
assert path.endswith('io.py')
|
||||
assert is_package is False
|
||||
|
||||
|
||||
def test_find_module_package_zipped():
|
||||
if 'zipped_imports/pkg.zip' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__),
|
||||
'zipped_imports/pkg.zip'))
|
||||
file, path, is_package = find_module('pkg')
|
||||
assert file is not None
|
||||
assert path.endswith('pkg.zip')
|
||||
assert is_package is True
|
||||
assert len(jedi.Script('import pkg; pkg.mod', 1, 19).completions()) == 1
|
||||
|
||||
|
||||
@pytest.mark.skipif('sys.version_info < (2,7)')
|
||||
def test_find_module_not_package_zipped():
|
||||
if 'zipped_imports/not_pkg.zip' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__),
|
||||
'zipped_imports/not_pkg.zip'))
|
||||
file, path, is_package = find_module('not_pkg')
|
||||
assert file is not None
|
||||
assert path.endswith('not_pkg.zip')
|
||||
assert is_package is False
|
||||
assert len(
|
||||
jedi.Script('import not_pkg; not_pkg.val', 1, 27).completions()) == 1
|
||||
|
||||
|
||||
@cwd_at('test/test_evaluate/not_in_sys_path/pkg')
|
||||
def test_import_not_in_sys_path():
|
||||
"""
|
||||
|
||||
BIN
test/test_evaluate/zipped_imports/not_pkg.zip
Normal file
BIN
test/test_evaluate/zipped_imports/not_pkg.zip
Normal file
Binary file not shown.
BIN
test/test_evaluate/zipped_imports/pkg.zip
Normal file
BIN
test/test_evaluate/zipped_imports/pkg.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user