Skip to content
Open
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
2 changes: 1 addition & 1 deletion metaflow/plugins/pypi/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def indices(self, prefix):
key, value = line.split("=", 1)
_, key = key.split(".")
if key in ("index-url", "extra-index-url"):
values = map(lambda x: x.strip("'\""), re.split("\s+", value, re.M))
values = map(lambda x: x.strip("'\""), re.split(r"\\n|\s+", value, re.M))
Comment thread
harkrish-1 marked this conversation as resolved.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks straightforward, good catch with this one.

Can you address the other pending review comments still? Otherwise this is good to go.

(indices if key == "index-url" else extra_indices).extend(values)
except Exception:
pass
Expand Down
24 changes: 24 additions & 0 deletions test/unit/test_pip_indices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from unittest.mock import patch
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use pytest, magicmock (pytest-mock plugin), and monkeypatch for the tests. Within pytest, we prefer to use fixtures and non-class-based tests.


from metaflow.plugins.pypi.pip import Pip


def _make_pip():
pip = object.__new__(Pip)
return pip


def test_multiple_extra_index_urls_literal_newline():
"""Regression test: pip config list separates multiple URLs with literal \\n."""
pip = _make_pip()
config_output = (
"global.index-url='https://pypi.org/simple'\n"
r"global.extra-index-url='https://extra1.example.com/simple'\n'https://extra2.example.com/simple'"
)
with patch.object(pip, "_call", return_value=config_output):
index, extras = pip.indices("dummy")
assert index == "https://pypi.org/simple"
assert extras == [
"https://extra1.example.com/simple",
"https://extra2.example.com/simple",
]
Loading