Skip to content

Commit

Permalink
list .venv when it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Dec 18, 2019
1 parent 00309a1 commit 868b59f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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")

(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()

0 comments on commit 868b59f

Please sign in to comment.