add more tests for version comparisons and reformat with black
This commit is contained in:
parent
6a5931b7dd
commit
3dec94dc85
2 changed files with 6 additions and 8 deletions
|
@ -165,10 +165,7 @@ class CargoSemVer:
|
|||
or (v1.major == v2.major and v1.minor == v2.minor and v1.patch > v2.patch)
|
||||
)
|
||||
elif op == CargoSemVer.KIND_GTE:
|
||||
return (
|
||||
CargoSemVer.eval_(v1, CargoSemVer.KIND_GT, v2)
|
||||
or CargoSemVer.eval_(v1, CargoSemVer.KIND_SHORTEQ, v2)
|
||||
)
|
||||
return CargoSemVer.eval_(v1, CargoSemVer.KIND_GT, v2) or CargoSemVer.eval_(v1, CargoSemVer.KIND_SHORTEQ, v2)
|
||||
elif op == CargoSemVer.KIND_LT:
|
||||
return (
|
||||
(v1.major < v2.major)
|
||||
|
@ -176,10 +173,7 @@ class CargoSemVer:
|
|||
or (v1.major == v2.major and v1.minor == v2.minor and v1.patch < v2.patch)
|
||||
)
|
||||
elif op == CargoSemVer.KIND_LTE:
|
||||
return (
|
||||
CargoSemVer.eval_(v1, CargoSemVer.KIND_LT, v2)
|
||||
or CargoSemVer.eval_(v1, CargoSemVer.KIND_SHORTEQ, v2)
|
||||
)
|
||||
return CargoSemVer.eval_(v1, CargoSemVer.KIND_LT, v2) or CargoSemVer.eval_(v1, CargoSemVer.KIND_SHORTEQ, v2)
|
||||
else:
|
||||
raise ValueError(f"Cannot evaluate operator: {op}")
|
||||
|
||||
|
|
|
@ -149,9 +149,13 @@ def test_coerce(version, coerced_version):
|
|||
"v1, op, v2, expected",
|
||||
[
|
||||
(Version(0, 2, 2, None, None), CargoSemVer.KIND_GT, Version(0, 3, 5, None, None), False),
|
||||
(Version(0, 2, 2, None, None), CargoSemVer.KIND_LT, Version(0, 3, 5, None, None), True),
|
||||
(Version(0, 2, 2, None, None), CargoSemVer.KIND_GTE, Version(0, 3, 5, None, None), False),
|
||||
(Version(0, 2, 2, None, None), CargoSemVer.KIND_LTE, Version(0, 3, 5, None, None), True),
|
||||
(Version(0, 3, 5, None, None), CargoSemVer.KIND_LT, Version(0, 2, 2, None, None), False),
|
||||
(Version(0, 3, 5, None, None), CargoSemVer.KIND_GT, Version(0, 2, 2, None, None), True),
|
||||
(Version(0, 3, 5, None, None), CargoSemVer.KIND_LTE, Version(0, 2, 2, None, None), False),
|
||||
(Version(0, 3, 5, None, None), CargoSemVer.KIND_GTE, Version(0, 2, 2, None, None), True),
|
||||
],
|
||||
)
|
||||
def test_eval(v1, op, v2, expected):
|
||||
|
|
Loading…
Reference in a new issue