|
15 | 15 | "" |
16 | 16 |
|
17 | 17 | load("@rules_testing//lib:test_suite.bzl", "test_suite") |
18 | | -load("//python/private/pypi:parse_requirements.bzl", "parse_requirements", "select_requirement") # buildifier: disable=bzl-visibility |
19 | | -load("//python/private/pypi:pep508_env.bzl", pep508_env = "env") # buildifier: disable=bzl-visibility |
| 18 | +load("//python/private:repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "REPO_VERBOSITY_ENV_VAR", "repo_utils") # buildifier: disable=bzl-visibility |
20 | 19 | load("//python/private/pypi:evaluate_markers.bzl", "evaluate_markers") # buildifier: disable=bzl-visibility |
| 20 | +load("//python/private/pypi:parse_requirements.bzl", "select_requirement", _parse_requirements = "parse_requirements") # buildifier: disable=bzl-visibility |
| 21 | +load("//python/private/pypi:pep508_env.bzl", pep508_env = "env") # buildifier: disable=bzl-visibility |
21 | 22 |
|
22 | 23 | def _mock_ctx(): |
23 | 24 | testdata = { |
@@ -104,9 +105,22 @@ bar==0.0.1 --hash=sha256:deadb00f |
104 | 105 |
|
105 | 106 | _tests = [] |
106 | 107 |
|
| 108 | +def parse_requirements(debug = False, **kwargs): |
| 109 | + return _parse_requirements( |
| 110 | + ctx = _mock_ctx(), |
| 111 | + logger = repo_utils.logger(struct( |
| 112 | + os = struct( |
| 113 | + environ = { |
| 114 | + REPO_DEBUG_ENV_VAR: "1", |
| 115 | + REPO_VERBOSITY_ENV_VAR: "TRACE" if debug else "INFO", |
| 116 | + }, |
| 117 | + ), |
| 118 | + ), "unit-test"), |
| 119 | + **kwargs |
| 120 | + ) |
| 121 | + |
107 | 122 | def _test_simple(env): |
108 | 123 | got = parse_requirements( |
109 | | - ctx = _mock_ctx(), |
110 | 124 | requirements_by_platform = { |
111 | 125 | "requirements_lock": ["linux_x86_64", "windows_x86_64"], |
112 | 126 | }, |
@@ -139,7 +153,6 @@ _tests.append(_test_simple) |
139 | 153 | def _test_direct_urls_integration(env): |
140 | 154 | """Check that we are using the filename from index_sources.""" |
141 | 155 | got = parse_requirements( |
142 | | - ctx = _mock_ctx(), |
143 | 156 | requirements_by_platform = { |
144 | 157 | "requirements_direct": ["linux_x86_64"], |
145 | 158 | "requirements_direct_sdist": ["osx_x86_64"], |
@@ -179,7 +192,6 @@ _tests.append(_test_direct_urls_integration) |
179 | 192 |
|
180 | 193 | def _test_extra_pip_args(env): |
181 | 194 | got = parse_requirements( |
182 | | - ctx = _mock_ctx(), |
183 | 195 | requirements_by_platform = { |
184 | 196 | "requirements_extra_args": ["linux_x86_64"], |
185 | 197 | }, |
@@ -211,7 +223,6 @@ _tests.append(_test_extra_pip_args) |
211 | 223 |
|
212 | 224 | def _test_dupe_requirements(env): |
213 | 225 | got = parse_requirements( |
214 | | - ctx = _mock_ctx(), |
215 | 226 | requirements_by_platform = { |
216 | 227 | "requirements_lock_dupe": ["linux_x86_64"], |
217 | 228 | }, |
@@ -240,7 +251,6 @@ _tests.append(_test_dupe_requirements) |
240 | 251 |
|
241 | 252 | def _test_multi_os(env): |
242 | 253 | got = parse_requirements( |
243 | | - ctx = _mock_ctx(), |
244 | 254 | requirements_by_platform = { |
245 | 255 | "requirements_linux": ["linux_x86_64"], |
246 | 256 | "requirements_windows": ["windows_x86_64"], |
@@ -304,7 +314,6 @@ _tests.append(_test_multi_os) |
304 | 314 |
|
305 | 315 | def _test_multi_os_legacy(env): |
306 | 316 | got = parse_requirements( |
307 | | - ctx = _mock_ctx(), |
308 | 317 | requirements_by_platform = { |
309 | 318 | "requirements_linux_download_only": ["cp39_linux_x86_64"], |
310 | 319 | "requirements_osx_download_only": ["cp39_osx_aarch64"], |
@@ -385,7 +394,6 @@ def _test_env_marker_resolution(env): |
385 | 394 | return ret |
386 | 395 |
|
387 | 396 | got = parse_requirements( |
388 | | - ctx = _mock_ctx(), |
389 | 397 | requirements_by_platform = { |
390 | 398 | "requirements_marker": ["cp311_linux_super_exotic", "cp311_windows_x86_64"], |
391 | 399 | }, |
@@ -432,7 +440,6 @@ _tests.append(_test_env_marker_resolution) |
432 | 440 |
|
433 | 441 | def _test_different_package_version(env): |
434 | 442 | got = parse_requirements( |
435 | | - ctx = _mock_ctx(), |
436 | 443 | requirements_by_platform = { |
437 | 444 | "requirements_different_package_version": ["linux_x86_64"], |
438 | 445 | }, |
@@ -471,7 +478,6 @@ _tests.append(_test_different_package_version) |
471 | 478 |
|
472 | 479 | def _test_optional_hash(env): |
473 | 480 | got = parse_requirements( |
474 | | - ctx = _mock_ctx(), |
475 | 481 | requirements_by_platform = { |
476 | 482 | "requirements_optional_hash": ["linux_x86_64"], |
477 | 483 | }, |
@@ -510,7 +516,6 @@ _tests.append(_test_optional_hash) |
510 | 516 |
|
511 | 517 | def _test_git_sources(env): |
512 | 518 | got = parse_requirements( |
513 | | - ctx = _mock_ctx(), |
514 | 519 | requirements_by_platform = { |
515 | 520 | "requirements_git": ["linux_x86_64"], |
516 | 521 | }, |
@@ -539,7 +544,6 @@ _tests.append(_test_git_sources) |
539 | 544 |
|
540 | 545 | def _test_overlapping_shas_with_index_results(env): |
541 | 546 | got = parse_requirements( |
542 | | - ctx = _mock_ctx(), |
543 | 547 | requirements_by_platform = { |
544 | 548 | "requirements_linux": ["cp39_linux_x86_64"], |
545 | 549 | "requirements_osx": ["cp39_osx_x86_64"], |
@@ -626,7 +630,6 @@ _tests.append(_test_overlapping_shas_with_index_results) |
626 | 630 |
|
627 | 631 | def _test_get_index_urls_different_versions(env): |
628 | 632 | got = parse_requirements( |
629 | | - ctx = _mock_ctx(), |
630 | 633 | requirements_by_platform = { |
631 | 634 | "requirements_multi_version": [ |
632 | 635 | "cp39_linux_x86_64", |
@@ -675,14 +678,14 @@ def _test_get_index_urls_different_versions(env): |
675 | 678 | evaluate_markers = lambda _, requirements: evaluate_markers( |
676 | 679 | requirements = requirements, |
677 | 680 | platforms = { |
678 | | - "cp39_linux_x86_64": struct( |
679 | | - env = {"python_full_version": "3.9.0"}, |
680 | | - ), |
681 | 681 | "cp310_linux_x86_64": struct( |
682 | 682 | env = {"python_full_version": "3.10.0"}, |
683 | 683 | ), |
| 684 | + "cp39_linux_x86_64": struct( |
| 685 | + env = {"python_full_version": "3.9.0"}, |
| 686 | + ), |
684 | 687 | }, |
685 | | - ) |
| 688 | + ), |
686 | 689 | ) |
687 | 690 |
|
688 | 691 | env.expect.that_collection(got).contains_exactly([ |
|
0 commit comments