Files
cibuildwheel/test/test_build_frontend_args.py
T
Henry Schreinerandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 097806b6b1 tests: fully type the test suite (#2794)
* tests: fully type the test suite

* chore: require more typing

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-01 15:23:02 +01:00

43 lines
1.3 KiB
Python

import subprocess
from pathlib import Path
import pytest
from . import test_projects, utils
@pytest.mark.parametrize(
"frontend_name",
[
pytest.param("pip", marks=utils.skip_if_pyodide("No pip for pyodide")),
"build",
],
)
def test_build_frontend_args(
tmp_path: Path, capfd: pytest.CaptureFixture[str], frontend_name: str
) -> None:
project = test_projects.new_c_project()
project_dir = tmp_path / "project"
project.generate(project_dir)
# the build will fail because the frontend is called with '-h' - it prints the help message
add_env = {"CIBW_BUILD_FRONTEND": f"{frontend_name}; args: -h"}
if utils.get_platform() == "pyodide":
add_env["TERM"] = "dumb" # disable color / style
add_env["NO_COLOR"] = "1"
with pytest.raises(subprocess.CalledProcessError):
utils.cibuildwheel_run(project_dir, add_env=add_env, single_python=True)
captured = capfd.readouterr()
print(captured.out)
# check that the help message was printed
if frontend_name == "pip":
assert "Usage:" in captured.out
assert "Wheel Options:" in captured.out
elif utils.get_platform() == "pyodide":
assert "Usage: pyodide build" in captured.out
else:
assert "usage:" in captured.out
assert "A simple, correct Python build frontend." in captured.out