Skip to content

Commit f503222

Browse files
committed
fix tests
1 parent 356ac94 commit f503222

File tree

2 files changed

+43
-29
lines changed

2 files changed

+43
-29
lines changed

python/private/pypi/parse_requirements.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def parse_requirements(
209209
struct(
210210
distribution = r.distribution,
211211
srcs = r.srcs,
212-
requirement_line = r.requirement_line,
213212
target_platforms = sorted(target_platforms),
214213
extra_pip_args = r.extra_pip_args,
215214
whls = whls,

tests/pypi/parse_requirements/parse_requirements_tests.bzl

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ load("//python/private/pypi:parse_requirements.bzl", "parse_requirements", "sele
2020
def _mock_ctx():
2121
testdata = {
2222
"requirements_different_package_version": """\
23-
foo==0.0.1+local --hash=sha256:deadbeef
24-
foo==0.0.1 --hash=sha256:deadb00f
23+
foo==0.0.1+local \
24+
--hash=sha256:deadbeef
25+
foo==0.0.1 \
26+
--hash=sha256:deadb00f
2527
""",
2628
"requirements_direct": """\
2729
foo[extra] @ https://some-url
2830
""",
2931
"requirements_extra_args": """\
3032
--index-url=example.org
3133
32-
foo[extra]==0.0.1 --hash=sha256:deadbeef
34+
foo[extra]==0.0.1 \
35+
--hash=sha256:deadbeef
3336
""",
3437
"requirements_linux": """\
3538
foo==0.0.3 --hash=sha256:deadbaaf
@@ -95,9 +98,12 @@ def _test_simple(env):
9598
struct(
9699
distribution = "foo",
97100
extra_pip_args = [],
98-
requirement_line = "foo[extra]==0.0.1 --hash=sha256:deadbeef",
101+
sdist = None,
102+
is_exposed = True,
99103
srcs = struct(
104+
marker = "",
100105
requirement = "foo[extra]==0.0.1",
106+
requirement_line = "foo[extra]==0.0.1 --hash=sha256:deadbeef",
101107
shas = ["deadbeef"],
102108
version = "0.0.1",
103109
),
@@ -106,8 +112,6 @@ def _test_simple(env):
106112
"windows_x86_64",
107113
],
108114
whls = [],
109-
sdist = None,
110-
is_exposed = True,
111115
),
112116
],
113117
})
@@ -133,18 +137,19 @@ def _test_extra_pip_args(env):
133137
struct(
134138
distribution = "foo",
135139
extra_pip_args = ["--index-url=example.org", "--trusted-host=example.org"],
136-
requirement_line = "foo[extra]==0.0.1 --hash=sha256:deadbeef",
140+
sdist = None,
141+
is_exposed = True,
137142
srcs = struct(
143+
marker = "",
138144
requirement = "foo[extra]==0.0.1",
145+
requirement_line = "foo[extra]==0.0.1 --hash=sha256:deadbeef",
139146
shas = ["deadbeef"],
140147
version = "0.0.1",
141148
),
142149
target_platforms = [
143150
"linux_x86_64",
144151
],
145152
whls = [],
146-
sdist = None,
147-
is_exposed = True,
148153
),
149154
],
150155
})
@@ -169,16 +174,17 @@ def _test_dupe_requirements(env):
169174
struct(
170175
distribution = "foo",
171176
extra_pip_args = [],
172-
requirement_line = "foo[extra,extra_2]==0.0.1 --hash=sha256:deadbeef",
177+
sdist = None,
178+
is_exposed = True,
173179
srcs = struct(
180+
marker = "",
174181
requirement = "foo[extra,extra_2]==0.0.1",
182+
requirement_line = "foo[extra,extra_2]==0.0.1 --hash=sha256:deadbeef",
175183
shas = ["deadbeef"],
176184
version = "0.0.1",
177185
),
178186
target_platforms = ["linux_x86_64"],
179187
whls = [],
180-
sdist = None,
181-
is_exposed = True,
182188
),
183189
],
184190
})
@@ -199,9 +205,10 @@ def _test_multi_os(env):
199205
struct(
200206
distribution = "bar",
201207
extra_pip_args = [],
202-
requirement_line = "bar==0.0.1 --hash=sha256:deadb00f",
203208
srcs = struct(
209+
marker = "",
204210
requirement = "bar==0.0.1",
211+
requirement_line = "bar==0.0.1 --hash=sha256:deadb00f",
205212
shas = ["deadb00f"],
206213
version = "0.0.1",
207214
),
@@ -215,9 +222,10 @@ def _test_multi_os(env):
215222
struct(
216223
distribution = "foo",
217224
extra_pip_args = [],
218-
requirement_line = "foo==0.0.3 --hash=sha256:deadbaaf",
219225
srcs = struct(
226+
marker = "",
220227
requirement = "foo==0.0.3",
228+
requirement_line = "foo==0.0.3 --hash=sha256:deadbaaf",
221229
shas = ["deadbaaf"],
222230
version = "0.0.3",
223231
),
@@ -229,9 +237,10 @@ def _test_multi_os(env):
229237
struct(
230238
distribution = "foo",
231239
extra_pip_args = [],
232-
requirement_line = "foo[extra]==0.0.2 --hash=sha256:deadbeef",
233240
srcs = struct(
241+
marker = "",
234242
requirement = "foo[extra]==0.0.2",
243+
requirement_line = "foo[extra]==0.0.2 --hash=sha256:deadbeef",
235244
shas = ["deadbeef"],
236245
version = "0.0.2",
237246
),
@@ -266,10 +275,11 @@ def _test_multi_os_legacy(env):
266275
distribution = "bar",
267276
extra_pip_args = ["--platform=manylinux_2_17_x86_64", "--python-version=39", "--implementation=cp", "--abi=cp39"],
268277
is_exposed = False,
269-
requirement_line = "bar==0.0.1 --hash=sha256:deadb00f",
270278
sdist = None,
271279
srcs = struct(
280+
marker = "",
272281
requirement = "bar==0.0.1",
282+
requirement_line = "bar==0.0.1 --hash=sha256:deadb00f",
273283
shas = ["deadb00f"],
274284
version = "0.0.1",
275285
),
@@ -282,10 +292,11 @@ def _test_multi_os_legacy(env):
282292
distribution = "foo",
283293
extra_pip_args = ["--platform=manylinux_2_17_x86_64", "--python-version=39", "--implementation=cp", "--abi=cp39"],
284294
is_exposed = True,
285-
requirement_line = "foo==0.0.1 --hash=sha256:deadbeef",
286295
sdist = None,
287296
srcs = struct(
297+
marker = "",
288298
requirement = "foo==0.0.1",
299+
requirement_line = "foo==0.0.1 --hash=sha256:deadbeef",
289300
shas = ["deadbeef"],
290301
version = "0.0.1",
291302
),
@@ -296,9 +307,10 @@ def _test_multi_os_legacy(env):
296307
distribution = "foo",
297308
extra_pip_args = ["--platform=macosx_10_9_arm64", "--python-version=39", "--implementation=cp", "--abi=cp39"],
298309
is_exposed = True,
299-
requirement_line = "foo==0.0.3 --hash=sha256:deadbaaf",
300310
sdist = None,
301311
srcs = struct(
312+
marker = "",
313+
requirement_line = "foo==0.0.3 --hash=sha256:deadbaaf",
302314
requirement = "foo==0.0.3",
303315
shas = ["deadbaaf"],
304316
version = "0.0.3",
@@ -348,10 +360,11 @@ def _test_env_marker_resolution(env):
348360
distribution = "bar",
349361
extra_pip_args = [],
350362
is_exposed = True,
351-
requirement_line = "bar==0.0.1 --hash=sha256:deadbeef",
352363
sdist = None,
353364
srcs = struct(
365+
marker = "",
354366
requirement = "bar==0.0.1",
367+
requirement_line = "bar==0.0.1 --hash=sha256:deadbeef",
355368
shas = ["deadbeef"],
356369
version = "0.0.1",
357370
),
@@ -363,12 +376,12 @@ def _test_env_marker_resolution(env):
363376
struct(
364377
distribution = "foo",
365378
extra_pip_args = [],
366-
# This is not exposed because we also have `linux_super_exotic` in the platform list
367379
is_exposed = False,
368-
requirement_line = "foo[extra]==0.0.1 ;marker --hash=sha256:deadbeef",
369380
sdist = None,
370381
srcs = struct(
371-
requirement = "foo[extra]==0.0.1 ;marker",
382+
marker = "marker",
383+
requirement = "foo[extra]==0.0.1",
384+
requirement_line = "foo[extra]==0.0.1 --hash=sha256:deadbeef",
372385
shas = ["deadbeef"],
373386
version = "0.0.1",
374387
),
@@ -398,30 +411,32 @@ def _test_different_package_version(env):
398411
struct(
399412
distribution = "foo",
400413
extra_pip_args = [],
401-
requirement_line = "foo==0.0.1 --hash=sha256:deadb00f",
414+
is_exposed = True,
415+
sdist = None,
402416
srcs = struct(
417+
marker = "",
403418
requirement = "foo==0.0.1",
419+
requirement_line = "foo==0.0.1 --hash=sha256:deadb00f",
404420
shas = ["deadb00f"],
405421
version = "0.0.1",
406422
),
407423
target_platforms = ["linux_x86_64"],
408424
whls = [],
409-
sdist = None,
410-
is_exposed = True,
411425
),
412426
struct(
413427
distribution = "foo",
414428
extra_pip_args = [],
415-
requirement_line = "foo==0.0.1+local --hash=sha256:deadbeef",
429+
is_exposed = True,
430+
sdist = None,
416431
srcs = struct(
432+
marker = "",
417433
requirement = "foo==0.0.1+local",
434+
requirement_line = "foo==0.0.1+local --hash=sha256:deadbeef",
418435
shas = ["deadbeef"],
419436
version = "0.0.1+local",
420437
),
421438
target_platforms = ["linux_x86_64"],
422439
whls = [],
423-
sdist = None,
424-
is_exposed = True,
425440
),
426441
],
427442
})

0 commit comments

Comments
 (0)