diff --git a/.travis.yml b/.travis.yml index f5b5f1cc..7b1b70a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,6 @@ matrix: - python: 3.7 env: - TOXENV=cov-py37 - - JEDI_TEST_ENVIRONMENT=37 # For now ignore pypy, there are so many issues that we don't really need # to run it. #- python: pypy diff --git a/test/conftest.py b/test/conftest.py index b023f185..64bc8be7 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,4 +1,5 @@ import os +import sys import subprocess from itertools import count @@ -7,12 +8,19 @@ import pytest from . import helpers from . import run 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.imports import _load_python_module from jedi.file_io import KnownContentFileIO 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): parser.addoption( @@ -93,9 +101,15 @@ def collect_static_analysis_tests(base_dir, test_files): def venv_path(tmpdir_factory, environment): if environment.version_info.major < 3: 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') - 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 # 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_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