Skip to content

Commit 3661b94

Browse files
authored
tox --showconfig -e py shows core configs (#2625)
Resolves #2624
1 parent 871d091 commit 3661b94

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

docs/changelog/2624.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``tox --showconfig -e py311`` reports tox section, though it should not - by :user:`gaborbernat`.

src/tox/session/cmd/legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def legacy(state: State) -> int:
9191
option = state.conf.options
9292
if option.show_config:
9393
option.list_keys_only = []
94-
option.show_core = True
94+
option.show_core = not bool(option.env)
9595
return show_config(state)
9696
if option.list_envs or option.list_envs_all:
9797
state.envs.on_empty_fallback_py = False

src/tox/session/env_select.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __iter__(self) -> Iterator[str]:
3333
if not self.is_all and self._names is not None: # pragma: no branch
3434
yield from self._names
3535

36+
def __bool__(self) -> bool:
37+
return bool(self._names)
38+
3639
def __str__(self) -> str:
3740
return "ALL" if self.is_all else ("<env_list>" if self.is_default_list else ",".join(self))
3841

tests/session/cmd/test_legacy.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ def test_legacy_show_config(tox_project: ToxProjectCreator, mocker: MockerFixtur
1818
assert outcome.state.conf.options.show_core is True
1919

2020

21+
def test_legacy_show_config_with_env(tox_project: ToxProjectCreator, mocker: MockerFixture) -> None:
22+
show_config = mocker.patch("tox.session.cmd.legacy.show_config")
23+
24+
outcome = tox_project({"tox.ini": ""}).run("le", "--showconfig", "-e", "py")
25+
26+
assert show_config.call_count == 1
27+
assert outcome.state.conf.options.list_keys_only == []
28+
assert outcome.state.conf.options.show_core is False
29+
30+
2131
@pytest.mark.parametrize("verbose", range(3))
2232
def test_legacy_list_default(tox_project: ToxProjectCreator, mocker: MockerFixture, verbose: int) -> None:
2333
list_env = mocker.patch("tox.session.cmd.legacy.list_env")

0 commit comments

Comments
 (0)