@@ -279,6 +279,46 @@ def test_scan_create_entrypoints(fake_config, tmp_path):
279279 assert "from a import main" in expect ["script_code" ]
280280
281281
282+ @pytest .mark .parametrize ("alias_set" , ["none" , "one" , "onew" , "two" ])
283+ def test_scan_create_entrypoints_with_alias (fake_config , tmp_path , alias_set ):
284+ # In this test, we fake the scan, but vary the set of aliases associated
285+ # with the installed runtime.
286+ # If there are no aliases, we shouldn't create any entrypoints.
287+ # If we have a non-windowed alias, we'll use that for both.
288+ # If we have a windowed alias, we'll only create windowed entrypoints.
289+ # If we have both, we'll use the appropriate one
290+
291+ def fake_scan (* a ):
292+ return [(dict (name = "a" , windowed = 0 ), "CODE" ),
293+ (dict (name = "aw" , windowed = 1 ), "CODE" )]
294+
295+ alias = {
296+ "none" : [],
297+ "one" : [dict (target = "test.exe" , windowed = 0 )],
298+ "onew" : [dict (target = "testw.exe" , windowed = 1 )],
299+ "two" : [dict (target = "test.exe" , windowed = 0 ),
300+ dict (target = "testw.exe" , windowed = 1 )],
301+ }[alias_set ]
302+
303+ expect = {
304+ "none" : [],
305+ "one" : [("a" , "test.exe" ), ("aw" , "test.exe" )],
306+ "onew" : [("aw" , "testw.exe" )],
307+ "two" : [("a" , "test.exe" ), ("aw" , "testw.exe" )],
308+ }[alias_set ]
309+
310+ created = []
311+ AU .scan_and_create_entrypoints (
312+ fake_config ,
313+ dict (prefix = fake_config .root , id = "test" , alias = alias ),
314+ {},
315+ _create_alias = lambda * a , ** kw : created .append ((a , kw )),
316+ _scan = fake_scan ,
317+ )
318+ names = [(c [0 ][2 ]["name" ], c [0 ][3 ].name ) for c in created ]
319+ assert names == expect
320+
321+
282322def test_scan_entrypoints (tmp_path ):
283323 site = tmp_path / "site"
284324 A = site / "a.dist-info"
0 commit comments