Skip to content

Commit 0acfd76

Browse files
committed
More test coverage
1 parent 1bd22d5 commit 0acfd76

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

tests/test_install_command.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import os
12
import pytest
23
import secrets
3-
from pathlib import PurePath
4+
from pathlib import Path, PurePath
45

56
from manage import install_command as IC
67
from manage import installs
@@ -101,16 +102,32 @@ def test_write_alias_fallback_platform(alias_checker):
101102
alias_checker.check_w64(alias_checker.Cmd("-spam"), "1.0", "testB")
102103

103104

104-
def test_print_cli_shortcuts(patched_installs, assert_log):
105+
def test_print_cli_shortcuts(patched_installs, assert_log, monkeypatch, tmp_path):
105106
class Cmd:
106-
global_dir = None
107+
global_dir = Path(tmp_path)
107108
def get_installs(self):
108109
return installs.get_installs(None)
109110

111+
(tmp_path / "fake.exe").write_bytes(b"")
112+
113+
monkeypatch.setitem(os.environ, "PATH", f"{os.environ['PATH']};{Cmd.global_dir}")
110114
IC.print_cli_shortcuts(Cmd())
111-
print(assert_log)
112115
assert_log(
113116
assert_log.skip_until("Installed %s", ["Python 2.0-64", PurePath("C:\\2.0-64")]),
114117
assert_log.skip_until("%s will be launched by %s", ["Python 1.0-64", "py1.0[-64].exe"]),
115118
("%s will be launched by %s", ["Python 1.0-32", "py1.0-32.exe"]),
116119
)
120+
121+
122+
def test_print_path_warning(patched_installs, assert_log, tmp_path):
123+
class Cmd:
124+
global_dir = Path(tmp_path)
125+
def get_installs(self):
126+
return installs.get_installs(None)
127+
128+
(tmp_path / "fake.exe").write_bytes(b"")
129+
130+
IC.print_cli_shortcuts(Cmd())
131+
assert_log(
132+
assert_log.skip_until(".*Global shortcuts directory is not on PATH")
133+
)

0 commit comments

Comments
 (0)