Skip to content

Commit

Permalink
POETRY_EXPERIMENTAL_NEW_INSTALLER is interpreted as a boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
AWhetter authored and neersighted committed Nov 15, 2021
1 parent 56f8163 commit d4c2fe4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
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

0 comments on commit d4c2fe4

Please sign in to comment.