"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/config/test_config.py" between
poetry-1.1.15.tar.gz and poetry-1.2.0.tar.gz

About: Poetry is a tool for dependency management and packaging in Python.

test_config.py  (poetry-1.1.15):test_config.py  (poetry-1.2.0)
from __future__ import annotations
import os import os
import re
from pathlib import Path
from typing import TYPE_CHECKING
import pytest import pytest
from flatdict import FlatDict
from poetry.config.config import Config
from poetry.config.config import boolean_normalizer
from poetry.config.config import int_normalizer
from collections.abc import Callable
from collections.abc import Iterator
def get_options_based_on_normalizer(normalizer: Callable) -> str:
flattened_config = FlatDict(Config.default_config, delimiter=".")
for k in flattened_config:
if Config._get_normalizer(k) == normalizer:
yield k
@pytest.mark.parametrize( @pytest.mark.parametrize(
("name", "value"), [("installer.parallel", True), ("virtualenvs.create", Tru e)] ("name", "value"), [("installer.parallel", True), ("virtualenvs.create", Tru e)]
) )
def test_config_get_default_value(config, name, value): def test_config_get_default_value(config: Config, name: str, value: bool):
assert config.get(name) is value assert config.get(name) is value
def test_config_get_processes_depended_on_values(config): def test_config_get_processes_depended_on_values(
assert os.path.join("/foo", "virtualenvs") == config.get("virtualenvs.path") config: Config, config_cache_dir: Path
assert str(config_cache_dir / "virtualenvs") == config.get("virtualenvs.path
def generate_environment_variable_tests() -> Iterator[tuple[str, str, str, bool]
for normalizer, values in [
(boolean_normalizer, [("true", True), ("false", False)]),
(int_normalizer, [("4", 4), ("2", 2)]),
for env_value, value in values:
for name in get_options_based_on_normalizer(normalizer=normalizer):
env_var = "POETRY_" + re.sub("[.-]+", "_", name).upper()
yield name, env_var, env_value, value
@pytest.mark.parametrize( @pytest.mark.parametrize(
("name", "env_value", "value"), ("name", "env_var", "env_value", "value"),
[ list(generate_environment_variable_tests()),
("installer.parallel", "true", True),
("installer.parallel", "false", False),
("virtualenvs.create", "true", True),
("virtualenvs.create", "false", False),
) )
def test_config_get_from_environment_variable(config, environ, name, env_value, def test_config_get_from_environment_variable(
value): config: Config,
env_var = "POETRY_{}".format("_".join(k.upper() for k in name.split("."))) environ: Iterator[None],
name: str,
env_var: str,
env_value: str,
value: bool,
os.environ[env_var] = env_value os.environ[env_var] = env_value
assert config.get(name) is value assert config.get(name) is value
("path_config", "expected"),
[("~/.venvs", Path.home() / ".venvs"), ("venv", Path("venv"))],
def test_config_expands_tilde_for_virtualenvs_path(
config: Config, path_config: str, expected: Path
config.merge({"virtualenvs": {"path": path_config}})
assert config.virtualenvs_path == expected
 End of changes. 8 change blocks. 
13 lines changed or deleted 50 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)