diff --git a/subiquity/common/snap.py b/subiquity/common/snap.py index 15aec836..3b626790 100644 --- a/subiquity/common/snap.py +++ b/subiquity/common/snap.py @@ -76,9 +76,9 @@ class SnapVersion: elif self.patch < other.patch: return False - if self.git_build_id is not None and other.git_build_id is None: - return True - elif self.git_build_id is None and other.git_build_id is not None: - return False + build_id_self = \ + float("-inf") if self.git_build_id is None else self.git_build_id + build_id_other = \ + float("-inf") if other.git_build_id is None else other.git_build_id - return self.git_build_id > other.git_build_id + return build_id_self > build_id_other diff --git a/subiquity/common/tests/test_snap.py b/subiquity/common/tests/test_snap.py index 0082ed8a..ddbc3724 100644 --- a/subiquity/common/tests/test_snap.py +++ b/subiquity/common/tests/test_snap.py @@ -43,3 +43,7 @@ class TestSnapVersion(unittest.TestCase): # Make sure we ignore the build ID when the patch version is different self.assertLess(SnapVersion.from_string("21.10.2+git255.deadbeef"), SnapVersion.from_string("21.10.3+git135.deadbeef")) + + snap_version = SnapVersion.from_string("21.10.02") + self.assertFalse(snap_version < snap_version) + self.assertFalse(snap_version > snap_version)