File: test_PythonVersionExtension.py

package info (click to toggle)
python-briefcase 0.3.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,596 kB
  • sloc: python: 62,519; makefile: 60
file content (75 lines) | stat: -rw-r--r-- 1,857 bytes parent folder | download
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from unittest.mock import MagicMock

import pytest

from briefcase.integrations.cookiecutter import PythonVersionExtension


@pytest.mark.parametrize(
    "value, expected",
    [
        # Single digit minor
        ("3.8.4.dev5", "3.8"),
        ("3.8.4a1", "3.8"),
        ("3.8.4b2", "3.8"),
        ("3.8.4rc3", "3.8"),
        ("3.8.4.post6", "3.8"),
        # Two digit minor
        ("3.11.4.dev5", "3.11"),
        ("3.11.4a1", "3.11"),
        ("3.11.4b2", "3.11"),
        ("3.11.4rc3", "3.11"),
        ("3.11.4.post6", "3.11"),
    ],
)
def test_py_tag(value, expected):
    env = MagicMock()
    env.filters = {}
    PythonVersionExtension(env)
    assert env.filters["py_tag"](value) == expected


@pytest.mark.parametrize(
    "value, expected",
    [
        # Single digit minor
        ("3.8.4.dev5", "38"),
        ("3.8.4a1", "38"),
        ("3.8.4b2", "38"),
        ("3.8.4rc3", "38"),
        ("3.8.4.post6", "38"),
        # Two digit minor
        ("3.11.4.dev5", "311"),
        ("3.11.4a1", "311"),
        ("3.11.4b2", "311"),
        ("3.11.4rc3", "311"),
        ("3.11.4.post6", "311"),
    ],
)
def test_py_libtag(value, expected):
    env = MagicMock()
    env.filters = {}
    PythonVersionExtension(env)
    assert env.filters["py_libtag"](value) == expected


@pytest.mark.parametrize(
    "value, expected",
    [
        # Single digit minor
        ("3.8.4", "3.8.4"),
        ("3.8.4a1", "3.8.4-a1"),
        ("3.8.4b2", "3.8.4-b2"),
        ("3.8.4rc3", "3.8.4-rc3"),
        # Two digit minor
        ("3.14.4", "3.14.4"),
        ("3.14.4a1", "3.14.4-a1"),
        ("3.14.4b2", "3.14.4-b2"),
        ("3.14.4rc3", "3.14.4-rc3"),
    ],
)
def test_nuget_version(value, expected):
    env = MagicMock()
    env.filters = {}
    PythonVersionExtension(env)
    assert env.filters["nuget_version"](value) == expected