Make it possible to explicitly state the version in pytest for different envs

This commit is contained in:
Dave Halter
2017-12-24 03:01:32 +01:00
parent a38acdbe08
commit 1f4e0dd22e

View File

@@ -1,7 +1,6 @@
import tempfile
import shutil
import os
import sys
import pytest
@@ -38,6 +37,9 @@ def pytest_addoption(parser):
parser.addoption("--warning-is-error", action='store_true',
help="Warnings are treated as errors.")
parser.addoption("--env", action='store',
help="Execute the tests in that environment (e.g. 35 for python3.5).")
def pytest_configure(config):
global jedi_cache_directory_orig, jedi_cache_directory_temp
@@ -82,8 +84,12 @@ def clean_jedi_cache(request):
@pytest.fixture(scope='session')
def environment():
version = os.environ.get('JEDI_TEST_ENVIRONMENT', str(py_version))
def environment(request):
if request is None:
version = os.environ.get('JEDI_TEST_ENVIRONMENT', str(py_version))
else:
version = request.config.option.env
if int(version) == py_version:
return get_default_environment()