Skip to content

Commit 5e4e8e7

Browse files
authored
Render placeholders in menu_name (#175)
* render 'menu_name' keys too * add test * tests use base_prefix * only test start menu * skip test if non-windows * try again * pre-commit * debug * try again * do remove in check_output * parent * break * add news
1 parent 9b8c0a1 commit 5e4e8e7

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

menuinst/platforms/win.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def start_menu_location(self) -> Path:
4949
In this property we only report the path to the Start menu.
5050
For other menus, check their respective properties.
5151
"""
52-
return Path(windows_folder_path(self.mode, False, "start")) / self.name
52+
return Path(windows_folder_path(self.mode, False, "start")) / self.render(self.name)
5353

5454
@property
5555
def quick_launch_location(self) -> Path:

news/175-render-menu-name

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Enhancements
2+
3+
* <news item>
4+
5+
### Bug fixes
6+
7+
* Render placeholders in `menu_name` key. (#175)
8+
9+
### Deprecations
10+
11+
* <news item>
12+
13+
### Docs
14+
15+
* <news item>
16+
17+
### Other
18+
19+
* <news item>

tests/data/jsons/sys-prefix.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json-schema.org/draft-07/schema",
33
"$id": "https://schemas.conda.io/menuinst-1.schema.json",
4-
"menu_name": "Sys.Prefix",
4+
"menu_name": "Sys.Prefix {{ DISTRIBUTION_NAME }}",
55
"menu_items": [
66
{
77
"name": "Sys.Prefix",

tests/test_api.py

+20-5
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,28 @@ def check_output_from_shortcut(
135135
if expected_output is not None:
136136
assert output.strip() == expected_output
137137

138-
return abs_json_path, paths, output
138+
return abs_json_path, paths, tmp_base_path, output
139139

140140

141141
def test_install_prefix(delete_files):
142142
check_output_from_shortcut(delete_files, "sys-prefix.json", expected_output=sys.prefix)
143143

144144

145+
@pytest.mark.skipif(PLATFORM != "win", reason="Windows only")
146+
def test_placeholders_in_menu_name(delete_files):
147+
_, paths, tmp_base_path, _ = check_output_from_shortcut(
148+
delete_files,
149+
"sys-prefix.json",
150+
expected_output=sys.prefix,
151+
)
152+
for path in paths:
153+
if path.suffix == ".lnk" and "Start Menu" in path.parts:
154+
assert path.parent.name == f"Sys.Prefix {Path(tmp_base_path).name}"
155+
break
156+
else:
157+
raise AssertionError("Didn't find Start Menu")
158+
159+
145160
def test_precommands(delete_files):
146161
check_output_from_shortcut(
147162
delete_files, "precommands.json", expected_output="rhododendron and bees"
@@ -150,7 +165,7 @@ def test_precommands(delete_files):
150165

151166
@pytest.mark.skipif(PLATFORM != "osx", reason="macOS only")
152167
def test_entitlements(delete_files):
153-
json_path, paths, _ = check_output_from_shortcut(
168+
json_path, paths, *_ = check_output_from_shortcut(
154169
delete_files, "entitlements.json", remove_after=False, expected_output="entitlements"
155170
)
156171
# verify signature
@@ -182,7 +197,7 @@ def test_entitlements(delete_files):
182197

183198
@pytest.mark.skipif(PLATFORM != "osx", reason="macOS only")
184199
def test_no_entitlements_no_signature(delete_files):
185-
json_path, paths, _ = check_output_from_shortcut(
200+
json_path, paths, *_ = check_output_from_shortcut(
186201
delete_files, "sys-prefix.json", remove_after=False, expected_output=sys.prefix
187202
)
188203
app_dir = next(p for p in paths if p.name.endswith(".app"))
@@ -198,7 +213,7 @@ def test_no_entitlements_no_signature(delete_files):
198213

199214
@pytest.mark.skipif(PLATFORM != "osx", reason="macOS only")
200215
def test_info_plist(delete_files):
201-
json_path, paths, _ = check_output_from_shortcut(
216+
json_path, paths, *_ = check_output_from_shortcut(
202217
delete_files, "entitlements.json", remove_after=False, expected_output="entitlements"
203218
)
204219
app_dir = next(p for p in paths if p.name.endswith(".app"))
@@ -217,7 +232,7 @@ def test_info_plist(delete_files):
217232

218233
@pytest.mark.skipif(PLATFORM != "osx", reason="macOS only")
219234
def test_osx_symlinks(delete_files):
220-
json_path, paths, output = check_output_from_shortcut(
235+
json_path, paths, _, output = check_output_from_shortcut(
221236
delete_files, "osx_symlinks.json", remove_after=False
222237
)
223238
app_dir = next(p for p in paths if p.name.endswith(".app"))

0 commit comments

Comments
 (0)