diff --git a/menuinst/platforms/win.py b/menuinst/platforms/win.py index a08833ea..88d3526e 100644 --- a/menuinst/platforms/win.py +++ b/menuinst/platforms/win.py @@ -49,7 +49,7 @@ def start_menu_location(self) -> Path: In this property we only report the path to the Start menu. For other menus, check their respective properties. """ - return Path(windows_folder_path(self.mode, False, "start")) / self.name + return Path(windows_folder_path(self.mode, False, "start")) / self.render(self.name) @property def quick_launch_location(self) -> Path: diff --git a/news/175-render-menu-name b/news/175-render-menu-name new file mode 100644 index 00000000..55408ed6 --- /dev/null +++ b/news/175-render-menu-name @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Render placeholders in `menu_name` key. (#175) + +### Deprecations + +* + +### Docs + +* + +### Other + +* diff --git a/tests/data/jsons/sys-prefix.json b/tests/data/jsons/sys-prefix.json index c42d2ae7..f44c1bf0 100644 --- a/tests/data/jsons/sys-prefix.json +++ b/tests/data/jsons/sys-prefix.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft-07/schema", "$id": "https://schemas.conda.io/menuinst-1.schema.json", - "menu_name": "Sys.Prefix", + "menu_name": "Sys.Prefix {{ DISTRIBUTION_NAME }}", "menu_items": [ { "name": "Sys.Prefix", diff --git a/tests/test_api.py b/tests/test_api.py index fb95cf53..9e43418e 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -135,13 +135,28 @@ def check_output_from_shortcut( if expected_output is not None: assert output.strip() == expected_output - return abs_json_path, paths, output + return abs_json_path, paths, tmp_base_path, output def test_install_prefix(delete_files): check_output_from_shortcut(delete_files, "sys-prefix.json", expected_output=sys.prefix) +@pytest.mark.skipif(PLATFORM != "win", reason="Windows only") +def test_placeholders_in_menu_name(delete_files): + _, paths, tmp_base_path, _ = check_output_from_shortcut( + delete_files, + "sys-prefix.json", + expected_output=sys.prefix, + ) + for path in paths: + if path.suffix == ".lnk" and "Start Menu" in path.parts: + assert path.parent.name == f"Sys.Prefix {Path(tmp_base_path).name}" + break + else: + raise AssertionError("Didn't find Start Menu") + + def test_precommands(delete_files): check_output_from_shortcut( delete_files, "precommands.json", expected_output="rhododendron and bees" @@ -150,7 +165,7 @@ def test_precommands(delete_files): @pytest.mark.skipif(PLATFORM != "osx", reason="macOS only") def test_entitlements(delete_files): - json_path, paths, _ = check_output_from_shortcut( + json_path, paths, *_ = check_output_from_shortcut( delete_files, "entitlements.json", remove_after=False, expected_output="entitlements" ) # verify signature @@ -182,7 +197,7 @@ def test_entitlements(delete_files): @pytest.mark.skipif(PLATFORM != "osx", reason="macOS only") def test_no_entitlements_no_signature(delete_files): - json_path, paths, _ = check_output_from_shortcut( + json_path, paths, *_ = check_output_from_shortcut( delete_files, "sys-prefix.json", remove_after=False, expected_output=sys.prefix ) 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): @pytest.mark.skipif(PLATFORM != "osx", reason="macOS only") def test_info_plist(delete_files): - json_path, paths, _ = check_output_from_shortcut( + json_path, paths, *_ = check_output_from_shortcut( delete_files, "entitlements.json", remove_after=False, expected_output="entitlements" ) app_dir = next(p for p in paths if p.name.endswith(".app")) @@ -217,7 +232,7 @@ def test_info_plist(delete_files): @pytest.mark.skipif(PLATFORM != "osx", reason="macOS only") def test_osx_symlinks(delete_files): - json_path, paths, output = check_output_from_shortcut( + json_path, paths, _, output = check_output_from_shortcut( delete_files, "osx_symlinks.json", remove_after=False ) app_dir = next(p for p in paths if p.name.endswith(".app"))