|
93 | 93 | [cwd, out, ['wheel'], {'--flag1': 'value', '--flag2': ['other_value', 'extra_value']}, True, False, None], |
94 | 94 | 'build_package_via_sdist', |
95 | 95 | ), |
| 96 | + ( |
| 97 | + ['--config-json={"one": 1, "two": [2, 3], "three": {"in": "out"}}'], |
| 98 | + [cwd, out, ['wheel'], {'one': 1, 'two': [2, 3], 'three': {'in': 'out'}}, True, False, None], |
| 99 | + 'build_package_via_sdist', |
| 100 | + ), |
| 101 | + ( |
| 102 | + ['--config-json', '{"outer": {"inner": {"deeper": 2}}}'], |
| 103 | + [cwd, out, ['wheel'], {'outer': {'inner': {'deeper': 2}}}, True, False, None], |
| 104 | + 'build_package_via_sdist', |
| 105 | + ), |
| 106 | + ( |
| 107 | + ['--config-json', '{}'], |
| 108 | + [cwd, out, ['wheel'], {}, True, False, None], |
| 109 | + 'build_package_via_sdist', |
| 110 | + ), |
96 | 111 | ], |
97 | 112 | ) |
98 | 113 | def test_parse_args(mocker, cli_args, build_args, hook): |
@@ -177,6 +192,22 @@ def test_build_no_isolation_with_check_deps(mocker, package_test_flit, missing_d |
177 | 192 | error.assert_called_with('Missing dependencies:' + output) |
178 | 193 |
|
179 | 194 |
|
| 195 | +@pytest.mark.parametrize( |
| 196 | + ['cli_args', 'err_msg'], |
| 197 | + [ |
| 198 | + (['-Cone=1', '--config-json={"two": 2}'], 'not allowed with argument'), |
| 199 | + (['--config-json={"two": 2'], 'Invalid JSON in --config-json'), |
| 200 | + (['--config-json=[1]'], '--config-json must contain a JSON object'), |
| 201 | + ], |
| 202 | +) |
| 203 | +def test_config_json_errors(cli_args, err_msg, capsys): |
| 204 | + with pytest.raises(SystemExit): |
| 205 | + build.__main__.main(cli_args) |
| 206 | + |
| 207 | + outerr = capsys.readouterr() |
| 208 | + assert err_msg in outerr.out or err_msg in outerr.err |
| 209 | + |
| 210 | + |
180 | 211 | @pytest.mark.isolated |
181 | 212 | def test_build_raises_build_exception(mocker, package_test_flit): |
182 | 213 | mocker.patch('build.ProjectBuilder.get_requires_for_build', side_effect=build.BuildException) |
|
0 commit comments