1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Percolate --use-feature from req file upwards

We explicitly propagate --use-feature options from req files upwards.
This is not strictly necessary for the option to be enabled, because
of the default value is a global list, but that implicit behaviour is
certainly accidental, so we make it explicit, with a test.
This commit is contained in:
Stéphane Bidoul 2020-07-25 11:11:36 +02:00
parent 7a3c802626
commit 38fe3c2f14
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
2 changed files with 16 additions and 6 deletions

View file

@ -225,12 +225,18 @@ def handle_option_line(
):
# type: (...) -> None
# percolate hash-checking option upward
if options and opts.require_hashes:
options.require_hashes = opts.require_hashes
if options:
# percolate options upward
if opts.require_hashes:
options.require_hashes = opts.require_hashes
if opts.features_enabled:
options.features_enabled.extend(
f for f in opts.features_enabled
if f not in options.features_enabled
)
# set finder options
elif finder:
if finder:
find_links = finder.find_links
index_urls = finder.index_urls
if opts.index_url:

View file

@ -47,6 +47,7 @@ def options(session):
isolated_mode=False,
index_url='default_url',
format_control=FormatControl(set(), set()),
features_enabled=[],
)
@ -382,9 +383,12 @@ class TestProcessLine(object):
line_processor("--pre", "file", 1, finder=finder)
assert finder.allow_all_prereleases
def test_use_feature(self, line_processor):
def test_use_feature(self, line_processor, options):
"""--use-feature can be set in requirements files."""
line_processor("--use-feature=2020-resolver", "filename", 1)
line_processor(
"--use-feature=2020-resolver", "filename", 1, options=options
)
assert "2020-resolver" in options.features_enabled
def test_relative_local_find_links(
self, line_processor, finder, monkeypatch, tmpdir