Skip to content

Commit

Permalink
Merge pull request #4408 from Flamefire/20231220133211_new_pr_ttolZmNdMU
Browse files Browse the repository at this point in the history
fix LooseVersion on Python2
  • Loading branch information
boegel authored Dec 20, 2023
2 parents 9ba76dd + 03d02e6 commit 5ee24a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions easybuild/tools/loose_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def _cmp(self, other):
def __eq__(self, other):
return self._cmp(other) == 0

def __ne__(self, other):
return self._cmp(other) != 0

def __lt__(self, other):
return self._cmp(other) < 0

Expand Down
11 changes: 10 additions & 1 deletion test/framework/utilities_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ def test_LooseVersion(self):
self.assertLess(LooseVersion('1.02'), '2.01')
self.assertLessEqual('1.02', LooseVersion('2.01'))
self.assertLessEqual(LooseVersion('1.02'), '2.01')
# Negation of all ops, i.e. verify each op can return False
self.assertFalse(LooseVersion('2.02') != '2.02')
self.assertFalse(LooseVersion('2.02') <= '2.01')
self.assertFalse(LooseVersion('2.02') < '2.01')
self.assertFalse(LooseVersion('2.02') < '2.02')
self.assertFalse(LooseVersion('2.02') == '2.03')
self.assertFalse(LooseVersion('2.02') >= '2.03')
self.assertFalse(LooseVersion('2.02') > '2.03')
self.assertFalse(LooseVersion('2.02') > '2.02')

# Some comparisons we might do: Full version on left hand side, shorter on right
self.assertGreater(LooseVersion('2.1.5'), LooseVersion('2.1'))
Expand All @@ -135,7 +144,7 @@ def test_LooseVersion(self):
self.assertGreater(LooseVersion('1.0'), LooseVersion('1'))
self.assertLess(LooseVersion('1'), LooseVersion('1.0'))

# The following test is taken from Python disutils tests
# The following test is taken from Python distutils tests
# licensed under the Python Software Foundation License Version 2
versions = (('1.5.1', '1.5.2b2', -1),
('161', '3.10a', 1),
Expand Down

0 comments on commit 5ee24a7

Please sign in to comment.