Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tox-dev/tox
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.4.1
Choose a base ref
...
head repository: tox-dev/tox
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.4.2
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Jan 25, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ed39bd7 View commit details
  2. release 4.4.2

    gaborbernat committed Jan 25, 2023

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    402cf84 View commit details
Showing with 24 additions and 13 deletions.
  1. +11 −0 docs/changelog.rst
  2. +1 −1 docs/config.rst
  3. +1 −1 src/tox/config/cli/ini.py
  4. +11 −11 tests/config/cli/test_cli_ini.py
11 changes: 11 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -4,6 +4,17 @@ Release History

.. towncrier release notes start
v4.4.2 (2023-01-25)
-------------------

Bugfixes - 4.4.2
~~~~~~~~~~~~~~~~
- Allow the user configuration file (default ``<appdir>/tox/config.ini``) to be overridden via the
``TOX_USER_CONFIG_FILE`` environment variable. Previously tox was looking at the ``TOX_CONFIG_FILE`` to override the
user configuration, however that environment variable is already used to override the main configuration - by
:user:`masenf`. (:issue:`2890`)


v4.4.1 (2023-01-25)
-------------------

2 changes: 1 addition & 1 deletion docs/config.rst
Original file line number Diff line number Diff line change
@@ -789,7 +789,7 @@ User configuration

tox allows creation of user level config-file to modify default values of the CLI commands.
It is located in the OS-specific user config directory under ``tox/config.ini`` path, see ``tox --help`` output for exact location.
It can be changed via ``TOX_CONFIG_FILE`` environment variable.
It can be changed via ``TOX_USER_CONFIG_FILE`` environment variable.
Example configuration:

.. code-block:: ini
2 changes: 1 addition & 1 deletion src/tox/config/cli/ini.py
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@


class IniConfig:
TOX_CONFIG_FILE_ENV_VAR = "TOX_CONFIG_FILE"
TOX_CONFIG_FILE_ENV_VAR = "TOX_USER_CONFIG_FILE"
STATE = {None: "failed to parse", True: "active", False: "missing"}

def __init__(self) -> None:
22 changes: 11 additions & 11 deletions tests/config/cli/test_cli_ini.py
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ def exhaustive_ini(tmp_path: Path, monkeypatch: MonkeyPatch) -> Path:
""",
),
)
monkeypatch.setenv("TOX_CONFIG_FILE", str(to))
monkeypatch.setenv("TOX_USER_CONFIG_FILE", str(to))
return to


@@ -58,7 +58,7 @@ def test_ini_empty(
content: str,
) -> None:
to = tmp_path / "tox.ini"
monkeypatch.setenv("TOX_CONFIG_FILE", str(to))
monkeypatch.setenv("TOX_USER_CONFIG_FILE", str(to))
to.write_text(content)
mocker.patch("tox.config.cli.parse.discover_source", return_value=mocker.MagicMock(path=Path()))
options = get_options("r")
@@ -73,7 +73,7 @@ def test_ini_empty(


@pytest.fixture()
def default_options(tmp_path: Path) -> dict[str, Any]:
def default_options() -> dict[str, Any]:
return {
"colored": "no",
"command": "r",
@@ -97,15 +97,16 @@ def default_options(tmp_path: Path) -> dict[str, Any]:
"verbose": 2,
"work_dir": None,
"root_dir": None,
"config_file": (tmp_path / "tox.ini").absolute(),
"config_file": None,
"factors": [],
"labels": [],
"exit_and_dump_after": 0,
"skip_env": "",
}


def test_ini_exhaustive_parallel_values(exhaustive_ini: Path, core_handlers: dict[str, Callable[[State], int]]) -> None:
@pytest.mark.usefixtures("exhaustive_ini")
def test_ini_exhaustive_parallel_values(core_handlers: dict[str, Callable[[State], int]]) -> None:
options = get_options("p")
assert vars(options.parsed) == {
"colored": "yes",
@@ -133,7 +134,7 @@ def test_ini_exhaustive_parallel_values(exhaustive_ini: Path, core_handlers: dic
"verbose": 5,
"work_dir": None,
"root_dir": None,
"config_file": exhaustive_ini,
"config_file": None,
"factors": [],
"labels": [],
"exit_and_dump_after": 0,
@@ -149,7 +150,7 @@ def test_ini_help(exhaustive_ini: Path, capsys: CaptureFixture) -> None:
assert context.value.code == 0
out, err = capsys.readouterr()
assert not err
assert f"config file '{exhaustive_ini}' active (changed via env var TOX_CONFIG_FILE)"
assert f"config file '{exhaustive_ini}' active (changed via env var TOX_USER_CONFIG_FILE)"


def test_bad_cli_ini(
@@ -161,15 +162,14 @@ def test_bad_cli_ini(
) -> None:
mocker.patch("tox.config.cli.parse.discover_source", return_value=mocker.MagicMock(path=Path()))
caplog.set_level(logging.WARNING)
monkeypatch.setenv("TOX_CONFIG_FILE", str(tmp_path))
monkeypatch.setenv("TOX_USER_CONFIG_FILE", str(tmp_path))
options = get_options("r")
msg = (
"PermissionError(13, 'Permission denied')"
if sys.platform == "win32"
else "IsADirectoryError(21, 'Is a directory')"
)
assert caplog.messages == [f"failed to read config file {tmp_path} because {msg}"]
default_options["config_file"] = tmp_path
assert vars(options.parsed) == default_options


@@ -191,7 +191,7 @@ def test_bad_option_cli_ini(
""",
),
)
monkeypatch.setenv("TOX_CONFIG_FILE", str(to))
monkeypatch.setenv("TOX_USER_CONFIG_FILE", str(to))
parsed, _, __, ___, ____ = get_options("r")
assert caplog.messages == [
"{} key verbose as type <class 'int'> failed with {}".format(
@@ -205,7 +205,7 @@ def test_bad_option_cli_ini(
def test_cli_ini_with_interpolated(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
to = tmp_path / "tox.ini"
to.write_text("[tox]\na = %(b)s")
monkeypatch.setenv("TOX_CONFIG_FILE", str(to))
monkeypatch.setenv("TOX_USER_CONFIG_FILE", str(to))
conf = IniConfig()
assert conf.get("a", str)