Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/manage/installs.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ def get_matching_install_tags(
exact_matches.append((i, t))
matched_any = True
elif not tag or tag.satisfied_by(ct):
if tag and not companies_match(tag.company, i["company"]):
if (
isinstance(tag, CompanyTag)
and not companies_match(tag.company, i["company"])
):
fallback_matches.append((i, t))
matched_any = True
elif i.get("unmanaged"):
Expand Down
12 changes: 10 additions & 2 deletions src/manage/tagutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __hash__(self):
return hash(self._sortkey)

def __eq__(self, other):
if other is None:
if not isinstance(other, type(self)):
return False
if self._company != other._company:
return False
Expand All @@ -232,6 +232,8 @@ def __eq__(self, other):
def __gt__(self, other):
if other is None:
return True
if not isinstance(other, type(self)):
return False
if self._company != other._company:
return self._company > other._company
if self._sortkey != other._sortkey:
Expand All @@ -243,6 +245,8 @@ def __gt__(self, other):
def matches_bound(self, other):
if other is None:
return True
if not isinstance(other, type(self)):
return False
if not self._company.startswith(other._company):
return False
if other.platform not in (self.platform, ""):
Expand All @@ -260,6 +264,8 @@ def matches_bound(self, other):
def above_lower_bound(self, other):
if other is None:
return True
if not isinstance(other, type(self)):
return False
if not self._company.startswith(other._company):
return False
if other.platform not in (self.platform, ""):
Expand All @@ -275,7 +281,7 @@ def above_lower_bound(self, other):
return True

def __lt__(self, other):
if other is None:
if not isinstance(other, type(self)):
return False
if self._company != other._company:
return self._company < other._company
Expand All @@ -288,6 +294,8 @@ def __lt__(self, other):
def below_upper_bound(self, other):
if other is None:
return True
if not isinstance(other, type(self)):
return False
if not self._company.startswith(other._company):
return False
if other.platform not in (self.platform, ""):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_installs.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def test_get_install_to_run_with_default_platform(patched_installs):
assert i["id"] == "PythonCore-2.0-64"
assert i["executable"].match("python.exe")


def test_get_install_to_run_with_default_platform_prerelease(patched_installs2):
# Specifically testing issue #25, where a native prerelease is preferred
# over a non-native stable release. We should prefer the stable release
Expand All @@ -158,3 +159,12 @@ def test_get_install_to_run_with_default_platform_prerelease(patched_installs2):
assert i["id"] == "PythonCore-1.0-32"
i = installs.get_install_to_run("<none>", None, None, default_platform="-arm64")
assert i["id"] == "PythonCore-1.0-32"


def test_get_install_to_run_with_range(patched_installs):
i = installs.get_install_to_run("<none>", None, "<=1.0")
assert i["id"] == "PythonCore-1.0"
assert i["executable"].match("python.exe")
i = installs.get_install_to_run("<none>", None, ">1.0")
assert i["id"] == "PythonCore-2.0-64"
assert i["executable"].match("python.exe")