mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Get the resolver name directly from test CLI
This commit is contained in:
parent
07ec3013f0
commit
6859de08d9
|
@ -39,16 +39,11 @@ def pytest_addoption(parser):
|
||||||
help="keep temporary test directories",
|
help="keep temporary test directories",
|
||||||
)
|
)
|
||||||
parser.addoption(
|
parser.addoption(
|
||||||
"--new-resolver",
|
"--resolver",
|
||||||
action="store_true",
|
action="store",
|
||||||
default=False,
|
default="2020-resolver",
|
||||||
help="use new resolver in tests",
|
choices=["2020-resolver", "legacy"],
|
||||||
)
|
help="use given resolver in tests",
|
||||||
parser.addoption(
|
|
||||||
"--new-resolver-runtests",
|
|
||||||
action="store_true",
|
|
||||||
default=False,
|
|
||||||
help="run the skipped tests for the new resolver",
|
|
||||||
)
|
)
|
||||||
parser.addoption(
|
parser.addoption(
|
||||||
"--use-venv",
|
"--use-venv",
|
||||||
|
@ -100,17 +95,17 @@ def pytest_collection_modifyitems(config, items):
|
||||||
def resolver_variant(request):
|
def resolver_variant(request):
|
||||||
"""Set environment variable to make pip default to the correct resolver.
|
"""Set environment variable to make pip default to the correct resolver.
|
||||||
"""
|
"""
|
||||||
new_resolver = request.config.getoption("--new-resolver")
|
resolver = request.config.getoption("--resolver")
|
||||||
|
|
||||||
|
# Handle the environment variables for this test.
|
||||||
features = set(os.environ.get("PIP_USE_FEATURE", "").split())
|
features = set(os.environ.get("PIP_USE_FEATURE", "").split())
|
||||||
if new_resolver:
|
if new_resolver:
|
||||||
retval = "2020-resolver"
|
|
||||||
features.add("2020-resolver")
|
features.add("2020-resolver")
|
||||||
else:
|
else:
|
||||||
retval = "legacy"
|
|
||||||
features.discard("2020-resolver")
|
features.discard("2020-resolver")
|
||||||
|
|
||||||
with patch.dict(os.environ, {"PIP_USE_FEATURE": " ".join(features)}):
|
with patch.dict(os.environ, {"PIP_USE_FEATURE": " ".join(features)}):
|
||||||
yield retval
|
yield resolver
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
|
|
Loading…
Reference in a new issue