Built in discovery class is always preferred over plugin supplied classes (#2088)
This commit is contained in:
parent
f198a65919
commit
625d5d8827
3 changed files with 17 additions and 2 deletions
1
docs/changelog/2087.bugfix.rst
Normal file
1
docs/changelog/2087.bugfix.rst
Normal file
|
|
@ -0,0 +1 @@
|
|||
Built in discovery class is always preferred over plugin supplied classes.
|
||||
|
|
@ -13,10 +13,13 @@ def get_discover(parser, args):
|
|||
title="discovery",
|
||||
description="discover and provide a target interpreter",
|
||||
)
|
||||
choices = _get_default_discovery(discover_types)
|
||||
# prefer the builtin if present, otherwise fallback to first defined type
|
||||
choices = sorted(choices, key=lambda a: 0 if a == "builtin" else 1)
|
||||
discovery_parser.add_argument(
|
||||
"--discovery",
|
||||
choices=_get_default_discovery(discover_types),
|
||||
default=next(i for i in discover_types.keys()),
|
||||
choices=choices,
|
||||
default=next(iter(choices)),
|
||||
required=False,
|
||||
help="interpreter discovery method",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -44,3 +44,14 @@ def test_reset_app_data_does_not_conflict_clear():
|
|||
session_via_cli(["--clear", "venv"], options=options)
|
||||
assert options.clear is True
|
||||
assert options.reset_app_data is False
|
||||
|
||||
|
||||
def test_builtin_discovery_class_preferred(mocker):
|
||||
mocker.patch(
|
||||
"virtualenv.run.plugin.discovery._get_default_discovery",
|
||||
return_value=["pluginA", "pluginX", "builtin", "Aplugin", "Xplugin"],
|
||||
)
|
||||
|
||||
options = VirtualEnvOptions()
|
||||
session_via_cli(["venv"], options=options)
|
||||
assert options.discovery == "builtin"
|
||||
|
|
|
|||
Loading…
Reference in a new issue