Skip to content
Open
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
10 changes: 10 additions & 0 deletions src/univers/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@ def __gt__(self, other):
return NotImplemented
return gentoo.vercmp(self.value, other.value) == 1

def __le__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
return gentoo.vercmp(self.value, other.value) <= 0

def __ge__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
return gentoo.vercmp(self.value, other.value) >= 0


class AlpineLinuxVersion(GentooVersion):
@classmethod
Expand Down
12 changes: 12 additions & 0 deletions tests/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ def test_rpm_version():
def test_gentoo_version():
assert GentooVersion("1.2.3") == GentooVersion("1.2.3")
assert GentooVersion("1.2.3") != GentooVersion("1.2.4")
assert GentooVersion("1.2.0-r0") < GentooVersion("1.10.0-r0")
assert GentooVersion("1.2.0-r0") <= GentooVersion("1.10.0-r0")
assert GentooVersion("1.10.0-r0") > GentooVersion("1.2.0-r0")
assert GentooVersion("1.10.0-r0") >= GentooVersion("1.2.0-r0")
assert not GentooVersion("1.10.0-r0") <= GentooVersion("1.2.0-r0")
assert not GentooVersion("1.2.0-r0") >= GentooVersion("1.10.0-r0")
assert GentooVersion("1.2.0-r0") <= GentooVersion("1.2.0-r0")
assert GentooVersion("1.2.0-r0") >= GentooVersion("1.2.0-r0")
assert GentooVersion.is_valid("1.2.3")
assert not GentooVersion.is_valid("1.2.3a-1-a")

Expand All @@ -181,6 +189,10 @@ def test_alpine_linux_version():
assert AlpineLinuxVersion("1.2.3-r1") < AlpineLinuxVersion("1.2.3-r2")
assert AlpineLinuxVersion("1.2.3-r1") >= AlpineLinuxVersion("1.2.3-r1")
assert AlpineLinuxVersion("1.2.3-r1") <= AlpineLinuxVersion("1.2.3-r1")
assert AlpineLinuxVersion("1.2.0-r0") <= AlpineLinuxVersion("1.10.0-r0")
assert AlpineLinuxVersion("1.10.0-r0") >= AlpineLinuxVersion("1.2.0-r0")
assert not AlpineLinuxVersion("1.10.0-r0") <= AlpineLinuxVersion("1.2.0-r0")
assert not AlpineLinuxVersion("1.2.0-r0") >= AlpineLinuxVersion("1.10.0-r0")
assert AlpineLinuxVersion.is_valid("1.2.3-r1")
assert not AlpineLinuxVersion.is_valid("007")

Expand Down