Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show host python under core section as constant #2644

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog/2630.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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