Skip to content

Commit

Permalink
tox --showconfig -e py shows core configs (#2625)
Browse files Browse the repository at this point in the history
Resolves #2624
  • Loading branch information
gaborbernat committed Dec 8, 2022
1 parent 871d091 commit 3661b94
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog/2624.bugfix.rst
@@ -0,0 +1 @@
``tox --showconfig -e py311`` reports tox section, though it should not - by :user:`gaborbernat`.
2 changes: 1 addition & 1 deletion src/tox/session/cmd/legacy.py
Expand Up @@ -91,7 +91,7 @@ def legacy(state: State) -> int:
option = state.conf.options
if option.show_config:
option.list_keys_only = []
option.show_core = True
option.show_core = not bool(option.env)
return show_config(state)
if option.list_envs or option.list_envs_all:
state.envs.on_empty_fallback_py = False
Expand Down
3 changes: 3 additions & 0 deletions src/tox/session/env_select.py
Expand Up @@ -33,6 +33,9 @@ def __iter__(self) -> Iterator[str]:
if not self.is_all and self._names is not None: # pragma: no branch
yield from self._names

def __bool__(self) -> bool:
return bool(self._names)

def __str__(self) -> str:
return "ALL" if self.is_all else ("<env_list>" if self.is_default_list else ",".join(self))

Expand Down
10 changes: 10 additions & 0 deletions tests/session/cmd/test_legacy.py
Expand Up @@ -18,6 +18,16 @@ def test_legacy_show_config(tox_project: ToxProjectCreator, mocker: MockerFixtur
assert outcome.state.conf.options.show_core is True


def test_legacy_show_config_with_env(tox_project: ToxProjectCreator, mocker: MockerFixture) -> None:
show_config = mocker.patch("tox.session.cmd.legacy.show_config")

outcome = tox_project({"tox.ini": ""}).run("le", "--showconfig", "-e", "py")

assert show_config.call_count == 1
assert outcome.state.conf.options.list_keys_only == []
assert outcome.state.conf.options.show_core is False


@pytest.mark.parametrize("verbose", range(3))
def test_legacy_list_default(tox_project: ToxProjectCreator, mocker: MockerFixture, verbose: int) -> None:
list_env = mocker.patch("tox.session.cmd.legacy.list_env")
Expand Down

0 comments on commit 3661b94

Please sign in to comment.