diff options
Diffstat (limited to 'tests/unit/test_pyproject_config.py')
-rw-r--r-- | tests/unit/test_pyproject_config.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/unit/test_pyproject_config.py b/tests/unit/test_pyproject_config.py new file mode 100644 index 000000000..9937f3880 --- /dev/null +++ b/tests/unit/test_pyproject_config.py @@ -0,0 +1,44 @@ +import pytest + +from pip._internal.commands import create_command + + +@pytest.mark.parametrize( + ("command", "expected"), + [ + ("install", True), + ("wheel", True), + ("freeze", False), + ], +) +def test_supports_config(command: str, expected: bool) -> None: + c = create_command(command) + options, _ = c.parse_args([]) + assert hasattr(options, "config_settings") == expected + + +def test_set_config_value_true() -> None: + i = create_command("install") + # Invalid argument exits with an error + with pytest.raises(SystemExit): + options, _ = i.parse_args(["xxx", "--config-settings", "x"]) + + +def test_set_config_value() -> None: + i = create_command("install") + options, _ = i.parse_args(["xxx", "--config-settings", "x=hello"]) + assert options.config_settings == {"x": "hello"} + + +def test_set_config_empty_value() -> None: + i = create_command("install") + options, _ = i.parse_args(["xxx", "--config-settings", "x="]) + assert options.config_settings == {"x": ""} + + +def test_replace_config_value() -> None: + i = create_command("install") + options, _ = i.parse_args( + ["xxx", "--config-settings", "x=hello", "--config-settings", "x=world"] + ) + assert options.config_settings == {"x": "world"} |