Skip to content

Commit

Permalink
Add a unit test for the TOML form of the option
Browse files Browse the repository at this point in the history
  • Loading branch information
joerick committed Aug 30, 2023
1 parent 061ea62 commit 81ef5fa
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions unit_test/options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,57 @@ def test_container_engine_option(tmp_path: Path, toml_assignment, result_name, r

assert parsed_container_engine.name == result_name
assert parsed_container_engine.create_args == result_create_args


@pytest.mark.parametrize(
("toml_assignment", "result_name", "result_args"),
[
(
"",
None,
None,
),
(
'build-frontend = "build"',
"build",
[],
),
(
'build-frontend = {name = "build"}',
"build",
[],
),
(
'build-frontend = "pip; args: --some-option"',
"pip",
["--some-option"],
),
(
'build-frontend = {name = "pip", args = ["--some-option"]}',
"pip",
["--some-option"],
),
],
)
def test_build_frontend_option(tmp_path: Path, toml_assignment, result_name, result_args):
args = CommandLineArguments.defaults()
args.package_dir = tmp_path

tmp_path.joinpath("pyproject.toml").write_text(
textwrap.dedent(
f"""\
[tool.cibuildwheel]
{toml_assignment}
"""
)
)

options = Options(platform="linux", command_line_arguments=args, env={})
parsed_build_frontend = options.build_options(identifier=None).build_frontend

if toml_assignment:
assert parsed_build_frontend is not None
assert parsed_build_frontend.name == result_name
assert parsed_build_frontend.args == result_args
else:
assert parsed_build_frontend is None

0 comments on commit 81ef5fa

Please sign in to comment.