Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POETRY_EXPERIMENTAL_NEW_INSTALLER is interpreted as a boolean #3811

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/poetry/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def _get_normalizer(self, name: str) -> Callable:
"virtualenvs.in-project",
"virtualenvs.options.always-copy",
"virtualenvs.options.system-site-packages",
"experimental.new-installer",
"installer.parallel",
}:
return boolean_normalizer
Expand Down
36 changes: 27 additions & 9 deletions tests/config/test_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import os
import re

import pytest

from poetry.config.config import Config


def get_boolean_options(config=None):
if config is None:
config = Config.default_config

for k, v in config.items():
if isinstance(v, bool) or v is None:
yield k
if isinstance(v, dict):
for suboption in get_boolean_options(v):
yield "{}.{}".format(k, suboption)


@pytest.mark.parametrize(
("name", "value"), [("installer.parallel", True), ("virtualenvs.create", True)]
Expand All @@ -14,16 +29,19 @@ def test_config_get_processes_depended_on_values(config, config_cache_dir):
assert str(config_cache_dir / "virtualenvs") == config.get("virtualenvs.path")


def generate_environment_variable_tests():
for env_value, value in [("true", True), ("false", False)]:
for name in get_boolean_options():
env_var = "POETRY_{}".format(re.sub("[.-]+", "_", name).upper())
yield (name, env_var, env_value, value)


@pytest.mark.parametrize(
("name", "env_value", "value"),
[
("installer.parallel", "true", True),
("installer.parallel", "false", False),
("virtualenvs.create", "true", True),
("virtualenvs.create", "false", False),
],
("name", "env_var", "env_value", "value"),
list(generate_environment_variable_tests()),
)
def test_config_get_from_environment_variable(config, environ, name, env_value, value):
env_var = "POETRY_{}".format("_".join(k.upper() for k in name.split(".")))
def test_config_get_from_environment_variable(
config, environ, name, env_var, env_value, value
):
os.environ[env_var] = env_value
assert config.get(name) is value