summaryrefslogtreecommitdiff
path: root/src/tox/tox_env/util.py
blob: aa13f12b9628d018081e3ef6359b9e4ad12a59f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from __future__ import annotations

from pathlib import Path
from typing import cast

from tox.config.sets import CoreConfigSet, EnvConfigSet


def add_change_dir_conf(config: EnvConfigSet, core: CoreConfigSet) -> None:
    def _post_process_change_dir(value: Path) -> Path:
        if not value.is_absolute():
            value = (core["tox_root"] / value).resolve()
        return value

    config.add_config(
        keys=["change_dir", "changedir"],
        of_type=Path,
        default=lambda conf, name: cast(Path, conf.core["tox_root"]),  # noqa: U100
        desc="change to this working directory when executing the test command",
        post_process=_post_process_change_dir,
    )


__all__ = [
    "add_change_dir_conf",
]