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

Fix legacy devenv #3019

Merged
merged 1 commit into from
May 27, 2023
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
5 changes: 4 additions & 1 deletion src/tox/session/env_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def __init__(self, state: State) -> None:
self.on_empty_fallback_py = True
self._warned_about: set[str] = set() #: shared set of skipped environments that were already warned about
self._state = state
self._cli_envs: CliEnv | None = getattr(self._state.conf.options, "env", None)
self._defined_envs_: None | dict[str, _ToxEnvInfo] = None
self._pkg_env_counter: Counter[str] = Counter()
from tox.plugin.manager import MANAGER
Expand All @@ -139,6 +138,10 @@ def __init__(self, state: State) -> None:
tox_env_filter_regex = getattr(state.conf.options, "skip_env", "").strip()
self._filter_re = re.compile(tox_env_filter_regex) if tox_env_filter_regex else None

@property
def _cli_envs(self) -> CliEnv | None:
return getattr(self._state.conf.options, "env", None)

def _collect_names(self) -> Iterator[tuple[Iterable[str], bool]]:
""":return: sources of tox environments defined with name and if is marked as target to run"""
if self._provision is not None: # pragma: no branch
Expand Down
11 changes: 11 additions & 0 deletions tests/session/test_env_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import pytest

from tox.config.cli.parse import get_options
from tox.pytest import MonkeyPatch, ToxProjectCreator
from tox.session.env_select import CliEnv, EnvSelector
from tox.session.state import State


def test_label_core_can_define(tox_project: ToxProjectCreator) -> None:
Expand Down Expand Up @@ -117,3 +120,11 @@ def test_tox_skip_env_logs(tox_project: ToxProjectCreator, monkeypatch: MonkeyPa
outcome = project.run("l", "--no-desc")
outcome.assert_success()
outcome.assert_out_err("ROOT: skip environment mypy, matches filter 'm[y]py'\npy310\npy39\n", "")


def test_env_select_lazily_looks_at_envs() -> None:
state = State(get_options(), [])
env_selector = EnvSelector(state)
# late-assigning env should be reflected in env_selector
state.conf.options.env = CliEnv("py")
assert set(env_selector.iter()) == {"py"}