Skip to content

Commit 19473bc

Browse files
committed
add string equality check for all and none versions
Signed-off-by: Kunz, Immanuel <immanuel.kunz@aisec.fraunhofer.de>
1 parent 00478f3 commit 19473bc

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/univers/versions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ def __str__(self):
134134

135135

136136
class AllVersion(Version):
137-
pass
137+
@classmethod
138+
def is_valid(cls, string):
139+
return string == "vers:all/*"
138140

139141

140142
class NoneVersion(Version):
141-
pass
143+
@classmethod
144+
def is_valid(cls, string):
145+
return string == "vers:none/*"
142146

143147

144148
class GenericVersion(Version):

tests/test_version_range.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,11 @@ def test_version_range_all():
552552
all_vers = VersionRange.from_string("vers:all/*")
553553
assert all_vers.contains(Version("1.2.3"))
554554
assert PypiVersion("2.0.3") in all_vers
555+
# test for invalid all range specification
556+
with pytest.raises(Exception):
557+
VersionRange.from_string("vers:all/>1.2.3")
558+
with pytest.raises(Exception):
559+
VersionRange.from_string("vers:all/*|>1.2.3")
555560

556561
def test_version_range_none():
557562
none_vers = VersionRange.from_string("vers:none/*")

0 commit comments

Comments
 (0)