File: test_utils.py

package info (click to toggle)
con-duct 0.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 584 kB
  • sloc: python: 4,324; sh: 22; makefile: 18
file content (42 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download | duplicates (2)
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
import pytest
from con_duct.utils import parse_version


@pytest.mark.parametrize(
    ("lesser", "greater"),
    [
        ("0.0.0", "1.0.0"),  # sanity
        ("0.2.0", "0.12.0"),  # each should value should be treated as an int
        ("0.99.99", "1.0.0"),  # X matters more than Y or Z
        ("0.0.99", "0.1.0"),  # Y matters more than Z
        ("3.2.1", "3.2.01"),  # Leading zeros are ok
    ],
)
def test_parse_version_green(lesser: str, greater: str) -> None:
    assert parse_version(greater) >= parse_version(lesser)


@pytest.mark.parametrize(
    ("invalid"),
    [
        "1",
        "1.1.1.1",  # Four shalt thou not count
        "1.1",  #  neither count thou two, excepting that thou then proceed to three
        "5.4.3.2.1",  # Five is right out
    ],
)
def test_parse_version_invalid_length(invalid: str) -> None:
    with pytest.raises(ValueError, match="Invalid version format"):
        parse_version(invalid)


@pytest.mark.parametrize(
    ("invalid"),
    [
        "a.b.c",
        "1.2.3a1",
    ],
)
def test_parse_version_invalid_type(invalid: str) -> None:
    with pytest.raises(ValueError, match="invalid literal for int"):
        parse_version(invalid)