Skip to content

Commit a996e3b

Browse files
authored
Merge pull request #2336 from sirosen/improve-build-deps-for-test
Enhance `--build-deps-for wheel` test
2 parents 5f31d8a + e00a17c commit a996e3b

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

tests/test_cli_compile.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,28 @@ def get_path_to(self, filename: str) -> str:
9494
)
9595

9696

97+
@dataclasses.dataclass
98+
class PackageVersionParam:
99+
"""
100+
An object for writing ergonomic test parameters.
101+
102+
This describes a published package with a version.
103+
"""
104+
105+
# package name
106+
name: str
107+
# (unparsed) version string
108+
version: str
109+
# a description of this version (for use in ids)
110+
description: str
111+
112+
def __str__(self) -> str:
113+
return f"{self.name}-{self.version}-{self.description}"
114+
115+
def as_req(self) -> str:
116+
return f"{self.name}=={self.version}"
117+
118+
97119
@pytest.fixture(
98120
autouse=True,
99121
params=[
@@ -3532,10 +3554,25 @@ def test_compile_recursive_extras_static(
35323554

35333555

35343556
@backtracking_resolver_only
3557+
@pytest.mark.parametrize(
3558+
"setuptools_version_info",
3559+
(
3560+
PackageVersionParam("setuptools", "82.0.0", "published-2026-02-08"),
3561+
PackageVersionParam("setuptools", "75.3.0", "published-2024-10-29"),
3562+
),
3563+
ids=str,
3564+
)
35353565
def test_compile_recursive_extras_build_targets(
3536-
runner, tmp_path, minimal_wheels_path, current_resolver
3566+
runner,
3567+
tmp_path,
3568+
minimal_wheels_path,
3569+
current_resolver,
3570+
setuptools_version_info,
35373571
):
3538-
(tmp_path / "pyproject.toml").write_text(dedent("""
3572+
(tmp_path / "pyproject.toml").write_text(dedent(f"""
3573+
[build-system]
3574+
requires = ["{setuptools_version_info.as_req()}"]
3575+
build-backend = "setuptools.build_meta"
35393576
[project]
35403577
name = "foo"
35413578
version = "0.0.1"
@@ -3544,6 +3581,7 @@ def test_compile_recursive_extras_build_targets(
35443581
footest = ["small-fake-b"]
35453582
dev = ["foo[footest]"]
35463583
"""))
3584+
35473585
out = runner.invoke(
35483586
cli,
35493587
[
@@ -3555,6 +3593,7 @@ def test_compile_recursive_extras_build_targets(
35553593
"dev",
35563594
"--build-deps-for",
35573595
"wheel",
3596+
"--allow-unsafe",
35583597
"--find-links",
35593598
minimal_wheels_path.as_posix(),
35603599
os.fspath(tmp_path / "pyproject.toml"),
@@ -3567,7 +3606,7 @@ def test_compile_recursive_extras_build_targets(
35673606
small-fake-b==0.3
35683607
35693608
# The following packages are considered to be unsafe in a requirements file:
3570-
# setuptools
3609+
{setuptools_version_info.as_req()}
35713610
"""
35723611
try:
35733612
assert out.exit_code == 0

0 commit comments

Comments
 (0)