forked from pypa/cibuildwheel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_build_frontend_args.py
39 lines (32 loc) · 1.23 KB
/
test_build_frontend_args.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import subprocess
import pytest
from . import utils
from .test_projects.c import new_c_project
@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, capfd, frontend_name):
project = 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.platform == "pyodide":
add_env["TERM"] = "dumb" # disable color / style
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.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