-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
test_list.py
58 lines (43 loc) · 1.44 KB
/
test_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import tomlkit
from cleo.testers import CommandTester
from poetry.utils._compat import Path
from poetry.utils.env import EnvManager
from poetry.utils.toml_file import TomlFile
def test_none_activated(app, tmp_dir):
app.poetry.config.merge({"virtualenvs": {"path": str(tmp_dir)}})
venv_name = EnvManager.generate_env_name(
"simple-project", str(app.poetry.file.parent)
)
(Path(tmp_dir) / "{}-py3.7".format(venv_name)).mkdir()
(Path(tmp_dir) / "{}-py3.6".format(venv_name)).mkdir()
command = app.find("env list")
tester = CommandTester(command)
tester.execute()
expected = """\
{}-py3.6
{}-py3.7
""".format(
venv_name, venv_name
)
assert expected == tester.io.fetch_output()
def test_activated(app, tmp_dir):
app.poetry.config.merge({"virtualenvs": {"path": str(tmp_dir)}})
venv_name = EnvManager.generate_env_name(
"simple-project", str(app.poetry.file.parent)
)
(Path(tmp_dir) / "{}-py3.7".format(venv_name)).mkdir()
(Path(tmp_dir) / "{}-py3.6".format(venv_name)).mkdir()
envs_file = TomlFile(Path(tmp_dir) / "envs.toml")
doc = tomlkit.document()
doc[venv_name] = {"minor": "3.7", "patch": "3.7.0"}
envs_file.write(doc)
command = app.find("env list")
tester = CommandTester(command)
tester.execute()
expected = """\
{}-py3.6
{}-py3.7 (Activated)
""".format(
venv_name, venv_name
)
assert expected == tester.io.fetch_output()