Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
list .venv when it exists
  • Loading branch information
frostming committed Dec 30, 2019
commit dd351f6b49c5f985b45c0b3ca558aad778598f0b
5 changes: 4 additions & 1 deletion poetry/console/commands/env/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ def handle(self):

manager = EnvManager(self.poetry)
current_env = manager.get()
env_list = manager.list()
if current_env not in env_list:
env_list.insert(0, current_env)

for venv in manager.list():
for venv in env_list:
name = venv.path.name
if self.option("full-path"):
name = str(venv.path)
Expand Down
16 changes: 16 additions & 0 deletions tests/console/commands/env/test_list.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import tomlkit

from cleo.testers import CommandTester
Expand Down Expand Up @@ -56,3 +58,17 @@ def test_activated(app, tmp_dir):
)

assert expected == tester.io.fetch_output()


def test_in_project_venv(app, tmpdir):
os.environ.pop("VIRTUAL_ENV", None)

(app.poetry.file.parent / ".venv").mkdir(exist_ok=True)

command = app.find("env list")
tester = CommandTester(command)
tester.execute()

expected = ".venv (Activated)\n"

assert expected == tester.io.fetch_output()