mirror of https://github.com/pypa/pip
Add pytest option to globally switch resolver
This commit is contained in:
parent
d911a9fcb8
commit
a82a5e7abe
|
@ -57,10 +57,10 @@ jobs:
|
|||
- stage: experimental
|
||||
env:
|
||||
- GROUP=1
|
||||
- PIP_UNSTABLE_FEATURE=resolver
|
||||
- NEW_RESOLVER=1
|
||||
- env:
|
||||
- GROUP=2
|
||||
- PIP_UNSTABLE_FEATURE=resolver
|
||||
- NEW_RESOLVER=1
|
||||
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
|
|
|
@ -30,11 +30,23 @@ if MYPY_CHECK_RUNNING:
|
|||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--keep-tmpdir", action="store_true",
|
||||
default=False, help="keep temporary test directories"
|
||||
"--keep-tmpdir",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="keep temporary test directories",
|
||||
)
|
||||
parser.addoption(
|
||||
"--new-resolver",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="use new resolver in tests",
|
||||
)
|
||||
parser.addoption(
|
||||
"--use-venv",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="use venv for virtual environment creation",
|
||||
)
|
||||
parser.addoption("--use-venv", action="store_true",
|
||||
help="use venv for virtual environment creation")
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(config, items):
|
||||
|
@ -75,6 +87,18 @@ def pytest_collection_modifyitems(config, items):
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def use_new_resolver(request):
|
||||
"""Set environment variable to make pip default to the new resolver.
|
||||
"""
|
||||
new_resolver = request.config.getoption("--new-resolver")
|
||||
if new_resolver:
|
||||
os.environ["PIP_UNSTABLE_FEATURE"] = "resolver"
|
||||
else:
|
||||
os.environ.pop("PIP_UNSTABLE_FEATURE", None)
|
||||
yield new_resolver
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def tmpdir_factory(request, tmpdir_factory):
|
||||
""" Modified `tmpdir_factory` session fixture
|
||||
|
|
|
@ -37,16 +37,24 @@ if [[ -z "$TOXENV" ]]; then
|
|||
fi
|
||||
echo "TOXENV=${TOXENV}"
|
||||
|
||||
if [[ -z "$NEW_RESOLVER" ]]; then
|
||||
RESOLVER_SWITCH=''
|
||||
else
|
||||
RESOLVER_SWITCH='--new-resolver'
|
||||
fi
|
||||
|
||||
# Print the commands run for this test.
|
||||
set -x
|
||||
if [[ "$GROUP" == "1" ]]; then
|
||||
# Unit tests
|
||||
tox -- --use-venv -m unit -n auto
|
||||
# Integration tests (not the ones for 'pip install')
|
||||
tox -- --use-venv -m integration -n auto --duration=5 -k "not test_install"
|
||||
tox -- -m integration -n auto --duration=5 -k "not test_install" \
|
||||
--use-venv $RESOLVER_SWITCH
|
||||
elif [[ "$GROUP" == "2" ]]; then
|
||||
# Separate Job for running integration tests for 'pip install'
|
||||
tox -- --use-venv -m integration -n auto --duration=5 -k "test_install"
|
||||
tox -- -m integration -n auto --duration=5 -k "test_install" \
|
||||
--use-venv $RESOLVER_SWITCH
|
||||
else
|
||||
# Non-Testing Jobs should run once
|
||||
tox
|
||||
|
|
Loading…
Reference in New Issue