Skip to content

Commit d62fc66

Browse files
authored
Fix devenv not respecting specified path (#2318)
1 parent dc2d3fa commit d62fc66

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
jobs:
13-
pre_commit:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-python@v2
18-
- uses: pre-commit/[email protected]
19-
2013
test:
2114
name: test ${{ matrix.py }} on ${{ matrix.os }}
2215
runs-on: ${{ matrix.os }}
@@ -110,7 +103,7 @@ jobs:
110103

111104
publish:
112105
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
113-
needs: [check, test, pre_commit]
106+
needs: [check, test]
114107
runs-on: ubuntu-20.04
115108
steps:
116109
- name: Setup python to build package

docs/changelog/2318.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``devenv`` command does not respect specified path - by :user:`gaborbernat`.

src/tox/session/cmd/devenv.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import logging
34
from pathlib import Path
45

56
from tox.config.cli.parser import ToxParser
@@ -23,12 +24,12 @@ def tox_add_option(parser: ToxParser) -> None:
2324

2425
def devenv(state: State) -> int:
2526
opt = state.conf.options
26-
2727
opt.skip_missing_interpreters = False # the target python must exist
2828
opt.no_test = False # do not run the test suite
2929
opt.package_only = False
3030
opt.install_pkg = None # no explicit packages to install
3131
opt.skip_pkg_install = False # always install a package in this case
32+
opt.no_test = True # do not run the test phase
3233

3334
state.envs.ensure_only_run_env_is_active()
3435
envs = list(state.envs.iter())
@@ -38,7 +39,9 @@ def devenv(state: State) -> int:
3839
usedevelop=True, # dev environments must be of type dev
3940
env_dir=Path(opt.devenv_path), # move it in source
4041
)
41-
42-
opt.no_test = True # do not run the test phase
43-
state.conf.get_env(envs[0], loaders=[loader])
44-
return run_sequential(state)
42+
tox_env = state.envs[envs[0]]
43+
tox_env.conf.loaders.insert(0, loader)
44+
result = run_sequential(state)
45+
if result == 0:
46+
logging.warning(f"created development environment under {tox_env.conf['env_dir']}")
47+
return result

tests/session/cmd/test_devenv.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ def test_devenv_fail_multiple_target(tox_project: ToxProjectCreator) -> None:
1515
@pytest.mark.integration()
1616
def test_devenv_ok(tox_project: ToxProjectCreator, enable_pip_pypi_access: str | None) -> None: # noqa: U100
1717
content = {"setup.py": "from setuptools import setup\nsetup(name='demo', version='1.0')"}
18-
outcome = tox_project(content).run("d", "-e", "py")
18+
project = tox_project(content)
19+
outcome = project.run("d", "-e", "py")
20+
1921
outcome.assert_success()
22+
assert (project.path / "venv").exists()
23+
assert f"created development environment under {project.path / 'venv'}" in outcome.out
2024

2125

2226
def test_devenv_help(tox_project: ToxProjectCreator) -> None:

0 commit comments

Comments
 (0)