1
0
forked from VimPlug/jedi
Files
jedi-fork/test/test_api/test_environment.py
Dave Halter 7263d8565b Add an access abstraction (only array tests work, yet)
The access abstraction will be the new way of accessing builtin objects. This way it will be easier to move that to another process
2017-11-25 19:47:49 +01:00

42 lines
1.0 KiB
Python

import pytest
import jedi
from jedi._compatibility import py_version
from jedi.api.virtualenv import Environment, DefaultEnvironment, NoVirtualEnv
def test_sys_path():
assert DefaultEnvironment('/foo').get_sys_path()
@pytest.mark.parametrize(
'version',
# TODO add '2.6', '2.7',
['3.3', '3.4', '3.5', '3.6', '3.7']
)
def test_versions(version):
executable = 'python' + version
try:
env = Environment('some path', executable)
except NoVirtualEnv:
if int(version.replace('.', '')) == py_version:
# At least the current version has to work
raise
return
sys_path = env.get_sys_path()
assert any(executable in p for p in sys_path)
@pytest.fixture
def evaluator():
return jedi.Script('')._evaluator
def test_import_module(evaluator):
compiled_obj = evaluator.compiled_subprocess.import_module(name='math')
assert compiled_obj.py__bool__() is True
assert compiled_obj.api_type == 'module'
with pytest.raises(AttributeError):
assert compiled_obj.py__mro__()