Skip to content

Commit 2e4203c

Browse files
authored
Allow any run-for tag to match in single_tag mode. (#61)
Fixes #57
1 parent c78e64b commit 2e4203c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/manage/installs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def get_matching_install_tags(
170170
else:
171171
matches.append((i, t))
172172
matched_any = True
173-
if single_tag:
173+
if single_tag and matched_any:
174174
break
175175
if LOGGER.would_log_to_console(DEBUG):
176176
# Don't bother listing all installs unless the user has asked

tests/test_installs.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def fake_get_installs(install_dir):
4040

4141
def fake_get_installs2(install_dir):
4242
yield make_install("1.0-32", sort_version="1.0")
43-
yield make_install("3.0a1-32", sort_version="3.0a1", run_for=["3-32", "3.0-32", "3.0a1-32"])
44-
yield make_install("3.0a1-64", sort_version="3.0a1", run_for=["3-64", "3.0-64", "3.0a1-64"])
45-
yield make_install("3.0a1-arm64", sort_version="3.0a1", run_for=["3-arm64", "3.0-arm64", "3.0a1-arm64"])
43+
yield make_install("3.0a1-32", sort_version="3.0a1", run_for=["3.0.1a1-32", "3.0-32", "3-32"])
44+
yield make_install("3.0a1-64", sort_version="3.0a1", run_for=["3.0.1a1-64", "3.0-64", "3-64"])
45+
yield make_install("3.0a1-arm64", sort_version="3.0a1", run_for=["3.0.1a1-arm64", "3.0-arm64", "3-arm64"])
4646

4747

4848
def fake_get_unmanaged_installs():
@@ -102,6 +102,17 @@ def test_get_default_with_default_platform(patched_installs):
102102
assert i["id"] == "PythonCore-1.0-32"
103103

104104

105+
def test_get_default_install_prerelease(patched_installs2):
106+
inst = list(installs._get_installs("<none>"))
107+
m = installs.get_matching_install_tags(inst, "1.0", None, "-32", single_tag=True)
108+
assert m and m[0]
109+
assert m[0][0]["id"] == "PythonCore-1.0-32"
110+
111+
m = installs.get_matching_install_tags(inst, "3.0", None, "-32", single_tag=True)
112+
assert m and m[0]
113+
assert m[0][0]["id"] == "PythonCore-3.0a1-32"
114+
115+
105116
def test_get_install_to_run(patched_installs):
106117
i = installs.get_install_to_run("<none>", None, "1.0")
107118
assert i["id"] == "PythonCore-1.0"

0 commit comments

Comments
 (0)