Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percolate --use-feature from req file upwards #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/pip/_internal/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def options(session):
isolated_mode=False,
index_url='default_url',
format_control=FormatControl(set(), set()),
features_enabled=[],
)


Expand Down Expand Up @@ -382,9 +383,12 @@ def test_set_finder_allow_all_prereleases(self, line_processor, finder):
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
Expand Down