forked from VimPlug/jedi
Get interpreter environment tests working
This commit is contained in:
@@ -21,7 +21,6 @@ matrix:
|
|||||||
- python: 3.7
|
- python: 3.7
|
||||||
env:
|
env:
|
||||||
- TOXENV=cov-py37
|
- TOXENV=cov-py37
|
||||||
- JEDI_TEST_ENVIRONMENT=37
|
|
||||||
# For now ignore pypy, there are so many issues that we don't really need
|
# For now ignore pypy, there are so many issues that we don't really need
|
||||||
# to run it.
|
# to run it.
|
||||||
#- python: pypy
|
#- python: pypy
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
|
||||||
@@ -7,12 +8,19 @@ import pytest
|
|||||||
from . import helpers
|
from . import helpers
|
||||||
from . import run
|
from . import run
|
||||||
from . import refactor
|
from . import refactor
|
||||||
from jedi.api.environment import InterpreterEnvironment
|
from jedi.api.environment import InterpreterEnvironment, get_system_environment
|
||||||
from jedi.inference.compiled.value import create_from_access_path
|
from jedi.inference.compiled.value import create_from_access_path
|
||||||
from jedi.inference.imports import _load_python_module
|
from jedi.inference.imports import _load_python_module
|
||||||
from jedi.file_io import KnownContentFileIO
|
from jedi.file_io import KnownContentFileIO
|
||||||
from jedi.inference.base_value import ValueSet
|
from jedi.inference.base_value import ValueSet
|
||||||
|
|
||||||
|
# For interpreter tests sometimes the path of this directory is in the sys
|
||||||
|
# path, which we definitely don't want. So just remove it globally.
|
||||||
|
try:
|
||||||
|
sys.path.remove(helpers.test_dir)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption(
|
parser.addoption(
|
||||||
@@ -93,9 +101,15 @@ def collect_static_analysis_tests(base_dir, test_files):
|
|||||||
def venv_path(tmpdir_factory, environment):
|
def venv_path(tmpdir_factory, environment):
|
||||||
if environment.version_info.major < 3:
|
if environment.version_info.major < 3:
|
||||||
pytest.skip("python -m venv does not exist in Python 2")
|
pytest.skip("python -m venv does not exist in Python 2")
|
||||||
|
elif isinstance(environment, InterpreterEnvironment):
|
||||||
|
# The environment can be a tox virtualenv environment which we don't
|
||||||
|
# want, so use the system environment.
|
||||||
|
environment = get_system_environment(
|
||||||
|
'.'.join(str(x) for x in environment.version_info[:2])
|
||||||
|
)
|
||||||
|
|
||||||
tmpdir = tmpdir_factory.mktemp('venv_path')
|
tmpdir = tmpdir_factory.mktemp('venv_path')
|
||||||
dirname = os.path.join(tmpdir.dirname, 'venv')
|
dirname = os.path.join(tmpdir.strpath, 'venv')
|
||||||
|
|
||||||
# We cannot use the Python from tox because tox creates virtualenvs and
|
# We cannot use the Python from tox because tox creates virtualenvs and
|
||||||
# they have different site.py files that work differently than the default
|
# they have different site.py files that work differently than the default
|
||||||
@@ -113,7 +127,8 @@ def venv_path(tmpdir_factory, environment):
|
|||||||
executable_name = os.path.basename(environment.executable)
|
executable_name = os.path.basename(environment.executable)
|
||||||
executable_path = os.path.join(prefix, 'bin', executable_name)
|
executable_path = os.path.join(prefix, 'bin', executable_name)
|
||||||
|
|
||||||
subprocess.call([executable_path, '-m', 'venv', dirname])
|
return_code = subprocess.call([executable_path, '-m', 'venv', dirname])
|
||||||
|
assert return_code == 0, return_code
|
||||||
return dirname
|
return dirname
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user