Skip to content

Commit 81ef5fa

Browse files
committed
Add a unit test for the TOML form of the option
1 parent 061ea62 commit 81ef5fa

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

unit_test/options_test.py

+54
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,57 @@ def test_container_engine_option(tmp_path: Path, toml_assignment, result_name, r
253253

254254
assert parsed_container_engine.name == result_name
255255
assert parsed_container_engine.create_args == result_create_args
256+
257+
258+
@pytest.mark.parametrize(
259+
("toml_assignment", "result_name", "result_args"),
260+
[
261+
(
262+
"",
263+
None,
264+
None,
265+
),
266+
(
267+
'build-frontend = "build"',
268+
"build",
269+
[],
270+
),
271+
(
272+
'build-frontend = {name = "build"}',
273+
"build",
274+
[],
275+
),
276+
(
277+
'build-frontend = "pip; args: --some-option"',
278+
"pip",
279+
["--some-option"],
280+
),
281+
(
282+
'build-frontend = {name = "pip", args = ["--some-option"]}',
283+
"pip",
284+
["--some-option"],
285+
),
286+
],
287+
)
288+
def test_build_frontend_option(tmp_path: Path, toml_assignment, result_name, result_args):
289+
args = CommandLineArguments.defaults()
290+
args.package_dir = tmp_path
291+
292+
tmp_path.joinpath("pyproject.toml").write_text(
293+
textwrap.dedent(
294+
f"""\
295+
[tool.cibuildwheel]
296+
{toml_assignment}
297+
"""
298+
)
299+
)
300+
301+
options = Options(platform="linux", command_line_arguments=args, env={})
302+
parsed_build_frontend = options.build_options(identifier=None).build_frontend
303+
304+
if toml_assignment:
305+
assert parsed_build_frontend is not None
306+
assert parsed_build_frontend.name == result_name
307+
assert parsed_build_frontend.args == result_args
308+
else:
309+
assert parsed_build_frontend is None

0 commit comments

Comments
 (0)