Skip to content

Commit

Permalink
[bugfix] Version int comparison (#12934)
Browse files Browse the repository at this point in the history
fixed error comparing between integers
  • Loading branch information
franramirez688 authored Jan 20, 2023
1 parent b7c012d commit 6e585bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conans/model/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __repr__(self):
def __eq__(self, other):
if other is None:
return False
if isinstance(other, str):
if not isinstance(other, Version):
other = Version(other)

return (self._nonzero_items, self._pre, self._build) ==\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ def test_comparison(v1, v2):
assert v2 >= v1


def test_comparison_with_integer():
v1 = Version("13.0")
# Issue: https://github.com/conan-io/conan/issues/12907
assert v1 > 5
assert not v1 > 20
assert v1 < 20
assert v1 == 13


e = [("1", "1.0"),
("1", "1.0.0"),
("1.0", "1.0.0"),
Expand Down

0 comments on commit 6e585bd

Please sign in to comment.