File: test_PythonVersionExtension.py

package info (click to toggle)
python-briefcase 0.3.22-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,296 kB
  • sloc: python: 59,405; makefile: 57
file content (53 lines) | stat: -rw-r--r-- 1,295 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
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