Skip to content

Commit

Permalink
add string equality check for all and none versions
Browse files Browse the repository at this point in the history
Signed-off-by: Kunz, Immanuel <[email protected]>
  • Loading branch information
immqu committed Nov 14, 2024
1 parent 00478f3 commit 19473bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/univers/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,15 @@ def __str__(self):


class AllVersion(Version):
pass
@classmethod
def is_valid(cls, string):
return string == "vers:all/*"


class NoneVersion(Version):
pass
@classmethod
def is_valid(cls, string):
return string == "vers:none/*"


class GenericVersion(Version):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ def test_version_range_all():
all_vers = VersionRange.from_string("vers:all/*")
assert all_vers.contains(Version("1.2.3"))
assert PypiVersion("2.0.3") in all_vers
# test for invalid all range specification
with pytest.raises(Exception):
VersionRange.from_string("vers:all/>1.2.3")
with pytest.raises(Exception):
VersionRange.from_string("vers:all/*|>1.2.3")

def test_version_range_none():
none_vers = VersionRange.from_string("vers:none/*")
Expand Down

0 comments on commit 19473bc

Please sign in to comment.