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 committed Mar 20, 2021
1 parent b1d380e commit 0c1e70d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions poetry/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def _get_normalizer(self, name: str) -> Callable:
"virtualenvs.create",
"virtualenvs.in-project",
"virtualenvs.options.always-copy",
"experimental.new-installer",
"installer.parallel",
}:
return boolean_normalizer
Expand Down
24 changes: 19 additions & 5 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 @@ -17,13 +32,12 @@ def test_config_get_processes_depended_on_values(config, config_cache_dir):
@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_value, value)
for name in get_boolean_options()
for env_value, value in [("true", True), ("false", False)]
],
)
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(".")))
env_var = "POETRY_{}".format(re.sub("[.-]+", "_", name).upper())
os.environ[env_var] = env_value
assert config.get(name) is value

0 comments on commit 0c1e70d

Please sign in to comment.