Skip to content
Snippets Groups Projects
Commit a33cf81e authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Reformat with Black.

parent e6024b3b
No related branches found
No related tags found
No related merge requests found
......@@ -24,83 +24,62 @@ cases = [
("1.0", "1.0", 0),
("1.0", "2.0", -1),
("2.0", "1.0", 1),
("2.0.1", "2.0.1", 0),
("2.0", "2.0.1", -1),
("2.0.1", "2.0", 1),
("2.0.1a", "2.0.1a", 0),
("2.0.1a", "2.0.1", 1),
("2.0.1", "2.0.1a", -1),
("5.5p1", "5.5p1", 0),
("5.5p1", "5.5p2", -1),
("5.5p2", "5.5p1", 1),
("5.5p10", "5.5p10", 0),
("5.5p1", "5.5p10", -1),
("5.5p10", "5.5p1", 1),
("10xyz", "10.1xyz", -1),
("10.1xyz", "10xyz", 1),
("xyz10", "xyz10", 0),
("xyz10", "xyz10.1", -1),
("xyz10.1", "xyz10", 1),
("xyz.4", "xyz.4", 0),
("xyz.4", "8", -1),
("8", "xyz.4", 1),
("xyz.4", "2", -1),
("2", "xyz.4", 1),
("5.5p2", "5.6p1", -1),
("5.6p1", "5.5p2", 1),
("5.6p1", "6.5p1", -1),
("6.5p1", "5.6p1", 1),
("6.0.rc1", "6.0", 1),
("6.0", "6.0.rc1", -1),
("10b2", "10a1", 1),
("10a2", "10b2", -1),
("1.0aa", "1.0aa", 0),
("1.0a", "1.0aa", -1),
("1.0aa", "1.0a", 1),
("10.0001", "10.0001", 0),
("10.0001", "10.1", 0),
("10.1", "10.0001", 0),
("10.0001", "10.0039", -1),
("10.0039", "10.0001", 1),
("4.999.9", "5.0", -1),
("5.0", "4.999.9", 1),
("20101121", "20101121", 0),
("20101121", "20101122", -1),
("20101122", "20101121", 1),
("2_0", "2_0", 0),
("2.0", "2_0", 0),
("2_0", "2.0", 0),
# Additional nastiness
("2_0.", "2_0", 0),
("2..0", "2_0__", 0),
("2_0", "__2.0", 0),
("2_1.", "2_0", +1),
("2..1", "2_0__", +1),
("2_1", "__2.0", +1),
("2_1.", "2_2", -1),
("2..1", "2_2__", -1),
("2_1", "__2.2", -1),
# https://bugzilla.redhat.com/178798
("a", "a", 0),
("a+", "a+", 0),
......@@ -114,7 +93,6 @@ cases = [
("_+", "_+", 0),
("+", "_", 0),
("_", "+", 0),
# Basic testcases for tilde sorting
("1.0~rc1", "1.0~rc1", 0),
("1.0~rc1", "1.0", -1),
......@@ -124,7 +102,6 @@ cases = [
("1.0~rc1~git123", "1.0~rc1~git123", 0),
("1.0~rc1~git123", "1.0~rc1", -1),
("1.0~rc1", "1.0~rc1~git123", 1),
("a", "a", 0),
("a~", "a", -1),
("a~~", "a", -1),
......@@ -135,7 +112,6 @@ cases = [
("a^", "a^", 0),
("a^", "a^^", -1),
("a^b", "a^^", +1),
# Basic testcases for caret sorting
("1.0^", "1.0^", 0),
("1.0^", "1.0", 1),
......@@ -153,7 +129,6 @@ cases = [
("1.0^20160101^git1", "1.0^20160101^git1", 0),
("1.0^20160102", "1.0^20160101^git1", 1),
("1.0^20160101^git1", "1.0^20160102", -1),
# Basic testcases for tilde and caret sorting
("1.0~rc1^git1", "1.0~rc1^git1", 0),
("1.0~rc1^git1", "1.0~rc1", 1),
......@@ -161,7 +136,6 @@ cases = [
("1.0^git1~pre", "1.0^git1~pre", 0),
("1.0^git1", "1.0^git1~pre", 1),
("1.0^git1~pre", "1.0^git1", -1),
# Additional testing for zeroes
("0", "0", 0),
("0", "00", 0),
......@@ -178,20 +152,24 @@ cases = [
("0^", "0^~", 1),
]
@pytest.mark.parametrize("a,b,expected", cases)
def test_version_comparisons(a, b, expected):
assert Version(a)._cmp(b) == expected
@pytest.mark.parametrize("a,b", [c[:2] for c in cases if c[2] < 0])
def test_version_lt(a, b):
assert Version(a) < b
assert Version(a) < Version(b)
@pytest.mark.parametrize("a,b", [c[:2] for c in cases if c[2] > 0])
def test_version_gt(a, b):
assert Version(a) > b
assert Version(a) > Version(b)
@pytest.mark.parametrize("a,b", [c[:2] for c in cases if c[2] == 0])
def test_version_gt(a, b):
assert Version(a) == b
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment