Skip to content

Commit b90dd58

Browse files
committed
test: add a test to ensure that the extra args are joined
However this is not a test for the code in question as those tests probably need to wait for bazel-contrib#2253 to land to make the test writing easier.
1 parent fe50515 commit b90dd58

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/pypi/parse_requirements/parse_requirements_tests.bzl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ def _mock_ctx():
2121
testdata = {
2222
"requirements_direct": """\
2323
foo[extra] @ https://some-url
24+
""",
25+
"requirements_extra_args": """\
26+
--index-url=example.org
27+
28+
foo[extra]==0.0.1 --hash=sha256:deadbeef
2429
""",
2530
"requirements_linux": """\
2631
foo==0.0.3 --hash=sha256:deadbaaf
@@ -93,6 +98,43 @@ def _test_simple(env):
9398

9499
_tests.append(_test_simple)
95100

101+
def _test_extra_pip_args(env):
102+
got = parse_requirements(
103+
ctx = _mock_ctx(),
104+
requirements_by_platform = {
105+
"requirements_extra_args": ["linux_x86_64"],
106+
},
107+
extra_pip_args = ["--trusted-host=example.org"],
108+
)
109+
env.expect.that_dict(got).contains_exactly({
110+
"foo": [
111+
struct(
112+
distribution = "foo",
113+
extra_pip_args = ["--index-url=example.org", "--trusted-host=example.org"],
114+
requirement_line = "foo[extra]==0.0.1 --hash=sha256:deadbeef",
115+
srcs = struct(
116+
requirement = "foo[extra]==0.0.1",
117+
shas = ["deadbeef"],
118+
version = "0.0.1",
119+
),
120+
target_platforms = [
121+
"linux_x86_64",
122+
],
123+
whls = [],
124+
sdist = None,
125+
is_exposed = True,
126+
),
127+
],
128+
})
129+
env.expect.that_str(
130+
select_requirement(
131+
got["foo"],
132+
platform = "linux_x86_64",
133+
).srcs.version,
134+
).equals("0.0.1")
135+
136+
_tests.append(_test_extra_pip_args)
137+
96138
def _test_dupe_requirements(env):
97139
got = parse_requirements(
98140
ctx = _mock_ctx(),

0 commit comments

Comments
 (0)