-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- boolean check for a sem-ver string - filter and sort a sequence of sem-ver strings - these utils are used to filter and sort a list of git tags
- Loading branch information
Darren Weber
committed
Aug 10, 2019
1 parent
1caf20a
commit 06200a9
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
|
||
from poetry.semver import is_sem_ver_constraint | ||
from poetry.semver import sem_ver_sorted | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"constraint,result", | ||
[ | ||
("*", True), | ||
("*.*", True), | ||
("v*.*", True), | ||
("*.x.*", True), | ||
("x.X.x.*", True), | ||
# ('!=1.0.0', Constraint('!=', '1.0.0.0')), | ||
(">1.0.0", True), | ||
("<1.2.3", True), | ||
("<=1.2.3", True), | ||
(">=1.2.3", True), | ||
("=1.2.3", True), | ||
("1.2.3", True), | ||
("=1.0", True), | ||
("1.2.3b5", True), | ||
(">= 1.2.3", True), | ||
(">dev", True), | ||
("hot-fix-666", False), | ||
], | ||
) | ||
def test_is_sem_ver_constraint(constraint, result): | ||
assert is_sem_ver_constraint(constraint) == result | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"unsorted, sorted_", | ||
[ | ||
(["1.0.3", "1.0.2", "1.0.1"], ["1.0.1", "1.0.2", "1.0.3"]), | ||
(["1.0.0.2", "1.0.0.0rc2"], ["1.0.0.0rc2", "1.0.0.2"]), | ||
(["1.0.0.0", "1.0.0.0rc2"], ["1.0.0.0rc2", "1.0.0.0"]), | ||
(["1.0.0.0.0", "1.0.0.0rc2"], ["1.0.0.0rc2", "1.0.0.0.0"]), | ||
(["1.0.0rc2", "1.0.0rc1"], ["1.0.0rc1", "1.0.0rc2"]), | ||
(["1.0.0rc2", "1.0.0b1"], ["1.0.0b1", "1.0.0rc2"]), | ||
(["1.0.3", "1.0.2", "1.0.1", "hot-fix-666"], ["1.0.1", "1.0.2", "1.0.3"]), | ||
], | ||
) | ||
def test_sem_ver_sorted(unsorted, sorted_): | ||
assert sem_ver_sorted(unsorted) == sorted_ |