Skip to content

Commit

Permalink
Show host python under core section as constant
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Dec 8, 2022
1 parent 267d327 commit 49d9706
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/2630.bugfix.rst
@@ -0,0 +1,2 @@
The core tox configuration now contains ``host_python`` key showing the host python executable path -
by :user:`gaborbernat`.
2 changes: 2 additions & 0 deletions src/tox/config/sets.py
@@ -1,5 +1,6 @@
from __future__ import annotations

import sys
from abc import ABC, abstractmethod
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Iterator, Mapping, Sequence, TypeVar, cast
Expand Down Expand Up @@ -202,6 +203,7 @@ def work_dir_builder(conf: Config, env_name: str | None) -> Path: # noqa: U100
default=lambda conf, _: cast(Path, self["work_dir"]) / ".tmp", # noqa: U100, U101
desc="a folder for temporary files (is not cleaned at start)",
)
self.add_constant("host_python", "the host python executable path", sys.executable)

def _on_duplicate_conf(self, key: str, definition: ConfigDefinition[V]) -> None: # noqa: U100
pass # core definitions may be defined multiple times as long as all their options match, first defined wins
Expand Down
7 changes: 7 additions & 0 deletions tests/session/cmd/test_show_config.py
Expand Up @@ -219,3 +219,10 @@ def test_show_config_timeout_custom(tox_project: ToxProjectCreator) -> None:
def test_show_config_help(tox_project: ToxProjectCreator) -> None:
outcome = tox_project({"tox.ini": ""}).run("c", "-h")
outcome.assert_success()


def test_show_config_core_host_python(tox_project: ToxProjectCreator) -> None:
project = tox_project({"tox.ini": ""})
outcome = project.run("c", "--core", "-e", "py", "-k", "host_python")
outcome.assert_success()
assert f"host_python = {sys.executable}" in outcome.out

0 comments on commit 49d9706

Please sign in to comment.