-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_semver.py
More file actions
54 lines (45 loc) · 1.01 KB
/
test_semver.py
File metadata and controls
54 lines (45 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pytest
from wlsonar._semver import _semver_is_less_than
@pytest.mark.parametrize(
"a, b",
[
("1.2.3", "1.2.4"),
("1.2.3", "1.3.0"),
("1.2.3", "2.0.0"),
],
)
def test_less_than(a: str, b: str) -> None:
assert _semver_is_less_than(a, b)
@pytest.mark.parametrize(
"a, b",
[
("1.2.3", "1.2.3"),
],
)
def test_equal(a: str, b: str) -> None:
assert not _semver_is_less_than(a, b)
@pytest.mark.parametrize(
"a, b",
[
("1.2.4", "1.2.3"),
("1.3.0", "1.2.9"),
("2.0.0", "1.9.9"),
],
)
def test_greater_than(a: str, b: str) -> None:
assert not _semver_is_less_than(a, b)
@pytest.mark.parametrize(
"a, b",
[
("1.2", "1.2.3"),
("1.2.3.4", "1.2.3"),
("abc", "1.2.3"),
("1.2.3", "xyz"),
("", "1.2.3"),
("1.2.3", ""),
(0, "1.2.3"),
],
)
def test_invalid_input_raises(a: str, b: str) -> None:
with pytest.raises(Exception):
_semver_is_less_than(a, b)