Skip to content

Commit c01bcf4

Browse files
authored
Ignore labels when provisioning (#2917)
Fix #2916
1 parent ae523ef commit c01bcf4

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

docs/changelog/2916.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Ignore labels when tox will provision a runtime environment (``.tox``) so that environment configurations which depend
2+
on provisioned plugins or specific tox versions are not accessed in the outer tox process where the configuration would
3+
be invalid - by :user:`masenf`.

src/tox/session/env_select.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ def _mark_active(self) -> None:
315315
if labels or factors:
316316
for env_info in self._defined_envs_.values():
317317
env_info.is_active = False # if any was selected reset
318-
if labels:
318+
# ignore labels when provisioning will occur
319+
if labels and (self._provision is None or not self._provision[0]):
319320
for label in labels:
320321
for env_name in self._state.conf.core["labels"].get(label, []):
321322
self._defined_envs_[env_name].is_active = True

tests/test_provision.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,21 @@ def test_provision_no_recreate_json(tox_project: ToxProjectCreator) -> None:
195195
def test_provision_plugin_runner(tox_project: ToxProjectCreator, tmp_path: Path, plugin_testenv: str) -> None:
196196
"""Ensure that testenv runner doesn't affect the provision env."""
197197
log = tmp_path / "out.log"
198-
proj = tox_project({"tox.ini": f"[tox]\nrequires=demo-pkg-inline\n[{plugin_testenv}]\nrunner=example"})
199-
result_first = proj.run("r", "-e", "py", "--result-json", str(log))
200-
result_first.assert_success()
198+
proj = tox_project(
199+
{"tox.ini": f"[tox]\nrequires=demo-pkg-inline\nlabels=l=py\n[{plugin_testenv}]\nrunner=example"},
200+
)
201201
prov_msg = (
202202
f"ROOT: will run in automatically provisioned tox, host {sys.executable} is missing"
203203
f" [requires (has)]: demo-pkg-inline"
204204
)
205-
assert prov_msg in result_first.out
205+
206+
result_env = proj.run("r", "-e", "py", "--result-json", str(log))
207+
result_env.assert_success()
208+
assert prov_msg in result_env.out
209+
210+
result_label = proj.run("r", "-m", "l", "--result-json", str(log))
211+
result_label.assert_success()
212+
assert prov_msg in result_label.out
206213

207214

208215
@pytest.mark.integration()

0 commit comments

Comments
 (0)