Debian Codegraph @

test/test_utils.py

raw symbols SCIP
1 import pytest
2 from con_duct._utils import parse_version
3
4
5 @pytest.mark.parametrize(
6 ("lesser", "greater"),
7 [
8 ("0.0.0", "1.0.0"), # sanity
9 ("0.2.0", "0.12.0"), # each should value should be treated as an int
10 ("0.99.99", "1.0.0"), # X matters more than Y or Z
11 ("0.0.99", "0.1.0"), # Y matters more than Z
12 ("3.2.1", "3.2.01"), # Leading zeros are ok
13 ],
14 )
15 def test_parse_version_green(lesser: str, greater: str) -> None:
16 assert parse_version(greater) >= parse_version(lesser)
17
18
19 @pytest.mark.parametrize(
20 ("invalid"),
21 [
22 "1",
23 "1.1.1.1", # Four shalt thou not count
24 "1.1", # neither count thou two, excepting that thou then proceed to three
25 "5.4.3.2.1", # Five is right out
26 ],
27 )
28 def test_parse_version_invalid_length(invalid: str) -> None:
29 with pytest.raises(ValueError, match="Invalid version format"):
30 parse_version(invalid)
31
32
33 @pytest.mark.parametrize(
34 ("invalid"),
35 [
36 "a.b.c",
37 "1.2.3a1",
38 ],
39 )
40 def test_parse_version_invalid_type(invalid: str) -> None:
41 with pytest.raises(ValueError, match="invalid literal for int"):
42 parse_version(invalid)