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

tox --showconfig -e py shows core configs #2625

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
1 change: 1 addition & 0 deletions docs/changelog/2624.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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