|
| 1 | +import os |
1 | 2 | import pytest |
2 | 3 | import secrets |
3 | | -from pathlib import PurePath |
| 4 | +from pathlib import Path, PurePath |
4 | 5 |
|
5 | 6 | from manage import install_command as IC |
6 | 7 | from manage import installs |
@@ -101,16 +102,32 @@ def test_write_alias_fallback_platform(alias_checker): |
101 | 102 | alias_checker.check_w64(alias_checker.Cmd("-spam"), "1.0", "testB") |
102 | 103 |
|
103 | 104 |
|
104 | | -def test_print_cli_shortcuts(patched_installs, assert_log): |
| 105 | +def test_print_cli_shortcuts(patched_installs, assert_log, monkeypatch, tmp_path): |
105 | 106 | class Cmd: |
106 | | - global_dir = None |
| 107 | + global_dir = Path(tmp_path) |
107 | 108 | def get_installs(self): |
108 | 109 | return installs.get_installs(None) |
109 | 110 |
|
| 111 | + (tmp_path / "fake.exe").write_bytes(b"") |
| 112 | + |
| 113 | + monkeypatch.setitem(os.environ, "PATH", f"{os.environ['PATH']};{Cmd.global_dir}") |
110 | 114 | IC.print_cli_shortcuts(Cmd()) |
111 | | - print(assert_log) |
112 | 115 | assert_log( |
113 | 116 | assert_log.skip_until("Installed %s", ["Python 2.0-64", PurePath("C:\\2.0-64")]), |
114 | 117 | assert_log.skip_until("%s will be launched by %s", ["Python 1.0-64", "py1.0[-64].exe"]), |
115 | 118 | ("%s will be launched by %s", ["Python 1.0-32", "py1.0-32.exe"]), |
116 | 119 | ) |
| 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