Commit def1ee8f by finswimmer Committed by GitHub

fix: fixed an issue where in-project venv wasn't listed

parent b1e1e14c
...@@ -734,7 +734,7 @@ class EnvManager: ...@@ -734,7 +734,7 @@ class EnvManager:
venv = self._poetry.file.parent / ".venv" venv = self._poetry.file.parent / ".venv"
if ( if (
self._poetry.config.get("virtualenvs.in-project") self._poetry.config.get("virtualenvs.in-project") is not False
and venv.exists() and venv.exists()
and venv.is_dir() and venv.is_dir()
): ):
......
...@@ -66,3 +66,29 @@ def venvs_in_project_dir(app: PoetryTestApplication) -> Iterator[Path]: ...@@ -66,3 +66,29 @@ def venvs_in_project_dir(app: PoetryTestApplication) -> Iterator[Path]:
yield venv_dir yield venv_dir
finally: finally:
venv_dir.rmdir() venv_dir.rmdir()
@pytest.fixture
def venvs_in_project_dir_none(app: PoetryTestApplication) -> Iterator[Path]:
os.environ.pop("VIRTUAL_ENV", None)
venv_dir = app.poetry.file.parent.joinpath(".venv")
venv_dir.mkdir(exist_ok=True)
app.poetry.config.merge({"virtualenvs": {"in-project": None}})
try:
yield venv_dir
finally:
venv_dir.rmdir()
@pytest.fixture
def venvs_in_project_dir_false(app: PoetryTestApplication) -> Iterator[Path]:
os.environ.pop("VIRTUAL_ENV", None)
venv_dir = app.poetry.file.parent.joinpath(".venv")
venv_dir.mkdir(exist_ok=True)
app.poetry.config.merge({"virtualenvs": {"in-project": False}})
try:
yield venv_dir
finally:
venv_dir.rmdir()
...@@ -60,3 +60,19 @@ def test_in_project_venv(tester: CommandTester, venvs_in_project_dir: list[str]) ...@@ -60,3 +60,19 @@ def test_in_project_venv(tester: CommandTester, venvs_in_project_dir: list[str])
tester.execute() tester.execute()
expected = ".venv (Activated)\n" expected = ".venv (Activated)\n"
assert tester.io.fetch_output() == expected assert tester.io.fetch_output() == expected
def test_in_project_venv_no_explicit_config(
tester: CommandTester, venvs_in_project_dir_none: list[str]
):
tester.execute()
expected = ".venv (Activated)\n"
assert tester.io.fetch_output() == expected
def test_in_project_venv_is_false(
tester: CommandTester, venvs_in_project_dir_false: list[str]
):
tester.execute()
expected = ""
assert tester.io.fetch_output() == expected
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment