-
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
Darren Weber
committed
Aug 23, 2019
1 parent
335da0d
commit c51df8f
Showing
2 changed files
with
79 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,52 @@ | ||
import pytest | ||
|
||
import poetry.semver | ||
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", True), | ||
(">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(mocker, constraint, result): | ||
parser = mocker.spy(poetry.semver, name="parse_single_constraint") | ||
assert is_sem_ver_constraint(constraint) == result | ||
assert parser.call_count == 1 | ||
|
||
|
||
@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"]), | ||
(["10.0.3", "1.0.3", "hot-fix-666"], ["1.0.3", "10.0.3"]), | ||
], | ||
) | ||
def test_sem_ver_sorted(mocker, unsorted, sorted_): | ||
parser = mocker.spy(poetry.semver, name="parse_single_constraint") | ||
assert sem_ver_sorted(unsorted) == sorted_ | ||
assert parser.call_count == len(sorted_) |