@@ -103,6 +103,47 @@ def test_write_alias_fallback_platform(alias_checker):
103103 alias_checker .check_w64 (alias_checker .Cmd ("-spam" ), "1.0" , "testB" )
104104
105105
106+ @pytest .mark .parametrize ("default" , [1 , 0 ])
107+ def test_write_alias_default (alias_checker , monkeypatch , tmp_path , default ):
108+ prefix = Path (tmp_path ) / "runtime"
109+
110+ class Cmd :
111+ global_dir = Path (tmp_path ) / "bin"
112+ launcher_exe = None
113+ def get_installs (self ):
114+ return [
115+ {
116+ "alias" : [
117+ {"name" : "python3.exe" , "target" : "p.exe" },
118+ {"name" : "pythonw3.exe" , "target" : "pw.exe" , "windowed" : 1 },
119+ ],
120+ "default" : default ,
121+ "prefix" : prefix ,
122+ }
123+ ]
124+
125+ prefix .mkdir (exist_ok = True , parents = True )
126+ (prefix / "p.exe" ).write_bytes (b"" )
127+ (prefix / "pw.exe" ).write_bytes (b"" )
128+
129+ written = []
130+ def write_alias (* a ):
131+ written .append (a )
132+
133+ monkeypatch .setattr (IC , "_write_alias" , write_alias )
134+ monkeypatch .setattr (IC , "SHORTCUT_HANDLERS" , {})
135+
136+ IC .update_all_shortcuts (Cmd ())
137+
138+ if default :
139+ # Main test: python.exe and pythonw.exe are added in automatically
140+ assert sorted (w [2 ]["name" ] for w in written ) == ["python.exe" , "python3.exe" , "pythonw.exe" , "pythonw3.exe" ]
141+ else :
142+ assert sorted (w [2 ]["name" ] for w in written ) == ["python3.exe" , "pythonw3.exe" ]
143+ # Ensure we still only have the two targets
144+ assert set (w [3 ].name for w in written ) == {"p.exe" , "pw.exe" }
145+
146+
106147def test_print_cli_shortcuts (patched_installs , assert_log , monkeypatch , tmp_path ):
107148 class Cmd :
108149 global_dir = Path (tmp_path )
0 commit comments