Skip to content

Commit 1a61f52

Browse files
committed
chore(test): add equality and misc version range cases
1 parent 42e3ef4 commit 1a61f52

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/constraints/version/test_version_range.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def v300b1() -> Version:
8181
@pytest.mark.parametrize(
8282
("constraint", "check_version", "allowed"),
8383
[
84+
# Inclusive ordering
8485
("<=3.0.0", "3.0.0+local.1", True),
8586
(">=3.0.0", "3.0.0+local.1", True),
8687
(">=3.0.0", "3.0.0-1", True),
@@ -114,6 +115,28 @@ def v300b1() -> Version:
114115
(">=3.0.0-1+local.1", "3.0.0-1", False),
115116
("<=3.0.0-2", "3.0.0-1", True),
116117
(">=3.0.0-2", "3.0.0-1", False),
118+
# Exclusive ordering
119+
(">1.7", "1.7.1", True),
120+
(">1.7", "1.6.1", False),
121+
("<1.7", "1.7.1", False),
122+
("<1.7", "1.6.1", True),
123+
## >V MUST NOT allow a post-release of the given version unless V itself is a post release
124+
(">1.7", "1.7.0.post1", False),
125+
(">1.7.post2", "1.7.0", False),
126+
(">1.7.post2", "1.7.1", True),
127+
(">1.7.post2", "1.7.0.post2", False),
128+
(">1.7.post2", "1.7.0.post3", True),
129+
## >V MUST NOT match a local version of the specified version
130+
(">1.7.0", "1.7.0+local.1", False),
131+
("<1.7.0", "1.7.0+local.1", False), # spec does not clarify this
132+
("<1.7.0+local.2", "1.7.0+local.1", False), # spec does not clarify this
133+
## <V MUST NOT allow a pre-release of the specified version unless the specified version is itself a pre-release
134+
("<1.7.0", "1.7.0.rc1", False),
135+
("<1.7.0.rc1", "1.7.0.rc1", False),
136+
("<1.7.0.rc2", "1.7.0.rc1", True),
137+
# Misc. Cases
138+
(">=3.0.0+cuda", "3.0.0+cuda", True),
139+
(">=3.0.0+cpu", "3.0.0+cuda", True), # cuda > cpu (lexicographically)
117140
],
118141
)
119142
def test_version_ranges(constraint: str, check_version: str, allowed: bool) -> None:

0 commit comments

Comments
 (0)